Hi,
I've found global functions (_G) to be generally unreliable in the past, so I figured I would use BindableEvents this time, and so far it's been much more organized.
However, for some reason, whenever I call my event to start the game process, it fails. No error message, and the rest of the code executes; it feels like it just skips the lines that fire the events.
Here's the snippet of code. I left out a ton of stuff in the function, but it shouldn't be important past knowing that it's running while the events are not.
EDIT: Also, the event IS being :connect'd in another snippet of code. I'll post it under this one.
function runGame() if #game.Players:GetChildren() < minPlayers.Value then return false end events.StartGame:Fire() inGame.Value = true currentTime.Value = gameTime.Value -- reset time -- code here that waits like 10 seconds, basically just consider this line a wait(10) events.EndGame:Fire() plagueActive.Value = false inGame.Value = false end
Here's the connecting code:
local events = game.ServerStorage.Events local testTable = {"Yes","No","Maybe so"} local minPlayers = game.ServerStorage.ReadValues.MinPlayers.Value script.Parent.Event:connect(function() print("Start game event fired.") events.LobbyToggle:Fire(false) events.KillAllPlayers:Fire() end)
Thanks, all replies are appreciated!
Did you add the connect argument for the event?
function onEvent() --event print('Hallo') end local event = Instance.new("BindableEvent") event.Parent = Workspace event.Event:connect(onEvent) event:Fire()