When to use bindableevents and does it "increase" performance or security?

Without binding an event

while true do
	local h = Instance.new("Hint")
	h.Text = "Meteors incoming, stay away from these fireballs!"
	h:Clone()
	local d = game:GetService("ServerStorage").Dup:Clone()
	wait(25)
	h.Parent = workspace
	d.Parent = workspace
	
end

With binding an event

local bevent = script.BindabeEvent
bevent.Event:Connect(function()
local h = Instance.new("Hint")
	h.Text = "Meteors incoming, stay away from these fireballs!"
	h:Clone()
	local d = game:GetService("ServerStorage").Dup:Clone()
	wait(25)
	h.Parent = workspace
	d.Parent = workspace
end)
while true do
wait(25)
bevent:Fire()
end

and that is pretty much the same thing as function but with a child of script
so is it better using this method in the future?

bindable events are for use inbetween different scripts rather than just one, they’re essentially functions that can be called anywhere


-- in 1 script
local bevent = script.BindableEvent
bevent.Event:Connect(function()
    local warning = Instance.new("Hint")
    warning.Text = "Meteors incoming, stay away from these fireballs!"

	local dup = game:GetService("ServerStorage").Dup:Clone()
	wait(25)
	warning.Parent = workspace
	dup.Parent = workspace
end)

-- In another *script*
local event = [whatever]
while true do
    wait(25)
    event:Fire()
end

they technically decrease security (it doesn’t really matter since local functions can be accessed anyway) and have little impact on performance

2 Likes