Bindable Event

Learn theory/Practice of BindableEvent!

by kirill2009bi

Author Avatar

Theory BindableEvent - This is an object that can be created in Explorer but you need scripts to work with it Replicated Storage - the best place to store your Bindable Event

Imagine that you create a function in your script and you can call this function from any other script To do this you need a Bindable Event You can create a BindableEvent through a script using instance.new("BindableEvent")

BindableEvent:Fire() - Call your BindableEvent bindableEvent.Event - Create a function that you can later call with a BindableEvent:Fire()


Practice Create your Bindable Event, name it "MyFirstBindableEvent" and put it in ReplicatedStorage

-- Create a new script and place it in ServerScriptService
local BindableEvent = game.ReplicatedStorage:WaitForChild("MyFirstBindableEvent") -- Our Bindable Event
BindableEvent.Event:Connect(function(msg)
	-- We have created a function and now we will call it in another script
	print("Hello world!")
end)
-- Script number 2
local BindableEvent = game.ReplicatedStorage:WaitForChild("MyFirstBindableEvent") -- Our bindable Event
BindableEvent:Fire() -- The Bindable Event has been called and now the Output will show us Hello world!

Parameters in BindableEvent There are also parameters Look carefully at the code and read the comments

local BindableEvent = game.ReplicatedStorage:WaitForChild("MyFirstBindableEvent") -- Our Bindable Event
BindableEvent.Event:Connect(function(msg)
	print(msg) -- The msg parameter is the message that we will have to respond to in script 2
end)
-- Script number 2
local BindableEvent = game.ReplicatedStorage:WaitForChild("MyFirstBindableEvent") -- Our bindable Event
BindableEvent:Fire("Hello world!") -- We responded to msg with the response "Hello world!" so if we run the game, the Output will respond “hello world!”

View in-game to comment, award, and more!