xft2008
(germ)
February 10, 2023, 10:34pm
#1
Bindable Event Firing Script:
if IsArcane.Value == true then
local Chance = ArcaneModule.ThriveChance()
print(tostring(Chance))
if Chance == 1 then
local RandomWait = math.random(12, 23)
BreakLightsEvent:Fire()
print("Fired Break Lights Event!")
wait(RandomWait)
if IsArcane.Value == true then
print("Spawned: 'Thrive'")
ActivateThrive()
end
else
end
end
(^^ works perfectly fine)
Bindable Event Receiving Script:
BreakLightsEvent.Event:Connect(function()
print("Got Break Light Event")
local RandomWait = math.random(3, 7)
wait(RandomWait)
LightPart.BrickColor = BrickColor.new("Black")
LightPart.Material = Enum.Material.Plastic
LightPart.Light.Enabled = false
LightBreakSound:Play()
Spark.Enabled = true
SparkSound:Play()
print("Broke Light")
wait(0.35)
Spark.Enabled = false
end)
I don’t know what is going on, I’ve tried many different solutions, and none seem to work.
Any help is appreciated!
gertkeno
(Gert)
February 10, 2023, 10:38pm
#2
So I am assuming “Fired Break Lights Event!” prints then nothing? but you expect “Got Break Light Event” to print as well.
If the first script happens before the connection is made that would prevent it, is the first script part of a function or runs immediately? does the second script run immediately? try adding a print above the connection too.
print("Connecting BreakLightsEvent!")
BreakLightsEvent.Event:Connect(function()
print("Got Break Light Event")
local RandomWait = math.random(3, 7)
1 Like
xft2008
(germ)
February 10, 2023, 10:39pm
#3
Fired Break Lights Event!
Prints, the Got Break Light Event
does not.
I have no clue why
(there are also no errors inside of output…)
2jammers
(2jammers)
February 10, 2023, 10:59pm
#4
There’s most likely a race condition here. Please make sure the event is connected before firing it.
2 Likes
xft2008
(germ)
February 10, 2023, 11:00pm
#5
How do I check if the event is connected?
2jammers
(2jammers)
February 10, 2023, 11:02pm
#6
When connecting an event, an RBXScriptConnection
is returned which has a Connected
boolean.
1 Like
xft2008
(germ)
February 10, 2023, 11:06pm
#7
It’s not, the event doesn’t even receive the Fire
function.
xft2008
(germ)
February 10, 2023, 11:10pm
#8
Sorry for the late response, but they are two seperate scripts. They are both in the same model, inside workspace.
gertkeno
(Gert)
February 10, 2023, 11:15pm
#9
Scripts can be run in any order roblox determines, they will not be run at the same time nor is it guaranteed to be the same order every time.
Could you try running with this print statement added right before the connection and post the output?
print("Connecting BreakLightsEvent!")
BreakLightsEvent.Event:Connect(function()
print("Got Break Light Event")
local RandomWait = math.random(3, 7)
1 Like
xft2008
(germ)
February 10, 2023, 11:17pm
#10
I just managed for it to work, I needed to add a wait()
Thank you to you andmaddjames28 for helping me though!
1 Like
2jammers
(2jammers)
February 10, 2023, 11:21pm
#11
This is what a race condition is. You should try to put all of your code in one script so it’s guaranteed that it runs at the same time.
system
(system)
Closed
February 24, 2023, 11:22pm
#12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.