BindableEvent
BindableEvent : Instance
Overview
A BindableEvent is an Object that enables asynchronous, one-way communication between scripts of the same kind, either between client-side scripts or between server-side scripts.
Functions connected to the event run independently on separate threads, so even if one function throws an error, the others will continue running without interruption.
If communication between the client and server is needed, use RemoteEvent instead.
Properties
Methods
Fire
Triggers the event associated with the BindableEvent.
Even if no functions are connected to the event or a connected function yields, the script that called this method will continue running without interruption.
Parameters
Tuple
Arguments
These are the arguments passed to the functions connected to a BindableEvent.
You can pass basic Luau data types such as number, boolean, string, and table.
Objects like Instances can also be passed.
However, not all data types are fully supported, so it's recommended to test how they behave before using them.
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
When the Fire method is called on a BindableEvent instance, all functions connected to its Event are run, and the arguments provided during the call are passed along as-is.
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)
See also
BindableEventLast updated