Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

BindableEvents not firing?

Asked by 9 years ago

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!

0
1) Are you sure that these lines are being run? (Have you `print`ed nearby the `:Fire()`s to make sure that's happening? 2) What about the code that's listening? Are you sure that's right? Are you sure its connection is actually running? BlueTaslem 18071 — 9y
0
I edited the original post, read the bold words. Tortelloni 315 — 9y
0
(As BlueTaslem suggests), Try adding a print statement before and after line 13 (in the first script) to make sure that the code you omitted is working correctly. chess123mate 5873 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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()
0
I edited the original post, read the bold words. Tortelloni 315 — 9y
Ad

Answer this question