I was programming today and (thought) I had this genius idea to communicate in my game when a round has ended and when voting has ended. Heres what I had (just showing the concept):
--VotingController = ModuleScript
--GameController = ModuleScript
while true do
VotingController:StartVoting()
VotingEnded.Event:Wait()
GameController:StartGame()
GameEnded.Event:Wait()
GameController:CleanUp()
wait()
end
However, I realized that script was still halting after I called BindableEvent:Fire() inside the module scripts. Why doesn't this work?
From my understanding, Bindables don't cross the client boundary, which means they only work in the environment they're used in. The same thing applies to ModuleScripts, which also don't cross the client/server boundary when required.
So, as I expected, if you require a modulescript on the server, its still in the environment of that script. Thus, I should be able to use BindableEvents just fine.
Heres some simpler code with that concept in mind:
--MODULE SCRIPT
--Instances
local Bindable = script.Parent:WaitForChild("Event")
--module
local module = {}
--public functions
function module:Func()
Bindable:Fire()
end
return module
--SERVER SCRIPT
--Instances
local Bindable = script:WaitForChild("Event")
--Modules
local Module = require(script:WaitForChild("ModuleScript"))
--Connections
Module:Func()
Bindable.Event:Wait()
print("Fired")
So, as I explained earlier, the script forever halts when I use Event:Wait().
Why does this happen?
(And yes, I did make sure that the functions in the module script were working correctly, it is firing the event just fine)
Thanks.

1 comment
aw yeah this is big brain time