BindableEvent

BindableEvent : Instance

Overview

BindableEvent is an instance class for braking one-way communication between scripts.

Description

The Bindable Event class is an object that enables asynchronous one-way communication between scripts, allowing users to create custom events and allow multiple scripts to communicate with each other within the same client-server boundary

Properties

Methods

Fire

Fire the event with Argument.

Parameters

Tuple Arguments

Return

void

Code Samples

-- Script1 (or LocalScript1)
local ServerScriptService = game:GetService("ServerScriptService")
local BindableEvent = ServerScriptService:WaitForChild("BindableEvent")

local function SomeEvent(text)
    print("[SomeEvent]", "Parameter : ", text)
end
BindableEvent.Event:Connect(SomeEvent)


-----------------------------------------------------------------------------------
-- Script2 (or LocalScript2)
local ServerScriptService = game:GetService("ServerScriptService")
local BindableEvent = ServerScriptService:WaitForChild("BindableEvent")

local SomeText = "BindableEvents"
BindableEvent:Fire(SomeText) -- Passing arguments

Events

Event

The Event represents the signal that is fired when the BindableEvent is triggered using the Fire method. Any connected functions to this event will be called, allowing scripts to respond to the event with any arguments that were provided when firing the event.

Parameters

Code Samples

local ServerScriptService = game:GetService("ServerScriptService")
local BindableEvent = ServerScriptService:WaitForChild("BindableEvent")

local function SomeEvent(text)
    print("[SomeEvent]", "Parameter : ", text)
end
BindableEvent.Event:Connect(SomeEvent)