From my understanding, the Event of BindableEvents allows for a function to be defined in one script and fired in another part of it, or in another script altogether of the same “scope” (server or client).
I was recently experimenting with BindableEvents and in Studio, I noticed something extremely odd.
Layout:
- One BindableEvent in Workspace
- One script in ServerScriptService [1]
- One local script in StarterPlayer.StarterPlayerScripts [2]
[1]
workspace.Event.Event:connect(function ()
print("hello from the server side")
end)
workspace.Event:Fire()
[2]
workspace.Event:Fire()
The result in Play Solo was the phrase defined in the server script being printed twice.
For my second test, I reversed the code in the scripts. The server called Fire() on the BindableEvent as its only line of code. The local script defined Event and fired the BindableEvent. This resulted in the phrase defined in the local script only being printed once.
Am I doing something wrong, is this Studio behavior or am I not getting something? I understood that scripts that call Fire() on the BindableEvent should only fire Event if it was defined in a script and vice versa for local scripts, but this test defied that.