Hello. So I was learning about BindableEvents and I was trying to fire a BindableFunction for it to print something to the output. The problem comes when I either run or play and when I do either it sometimes prints to the output and sometimes doesn't, I believe that the script may run before the BindableEvent even loads, and this is what WaitForChild() is for, but it looks like that it is not waiting for the BindableEvent and that sometimes it works and sometimes doesn't.
This is the script that fires the BindableEvent:
PrintStuff = game.Workspace:WaitForChild("PrintStuff") PrintStuff:Fire()
This is the scripts that picks up the BindableEvent:
PrintStuff = game.Workspace:WaitForChild("PrintStuff") function printSomething() print("Stuff") end PrintStuff.Event:Connect(printSomething)
This is an image of the Explorer folder in case it is needed:
The expected output would be that the BindableEvent would fire and print "Stuff" every time I either run or play.
Try waiting a few seconds before you fire. You shouldn't need to do this in most cases, but since you're testing it when both scripts load at the same time it is necessary.
PrintStuff = game.Workspace:WaitForChild("PrintStuff") function printSomething() print("Stuff") end wait (10) PrintStuff.Event:Connect(printSomething)