So basically I have a light that flashes on and off, shown here
local F_L = coroutine.create(function()
while wait(.4) do
script.Parent.Alarm_Trigger.Alarm.Strobe.Flash.Enabled = true
wait(.3)
script.Parent.Alarm_Trigger.Alarm.Strobe.Flash.Enabled = false
wait(.3)
end
end)
Basically this is so I can control the flash below:
But I can’t because it’s in a coroutine. I’ve tried bool values, brightness, destroying the flash and re adding but nothing is working.
The goal is to have the flash turn off when the alarm is turned off and have the flash turn on when the alarm is on (so like pause the coroutine in the other script when the alarm is off and then turn it back on when its on)
Just make a bindable event. When you want the flash to turn off/on, just fire the bindable event (from any script), and within the script that contains the coroutine, create a function connected to the bindable event that will pause/resume the coroutine upon the BindableEvent being fired.
Alright so I gave that a crack and got no luck with it, I’ve never used bindable events so I’m a bit of a beginner to them, I read up on the document about them, here’s what I got
Separate script:
local r_s = game.ReplicatedStorage
local F_L = coroutine.create(function()
while wait(.4) do
script.Parent.Alarm_Trigger.Alarm.Strobe.Flash.Enabled = true
wait(.3)
script.Parent.Alarm_Trigger.Alarm.Strobe.Flash.Enabled = false
wait(.3)
end
end)
r_s.AlarmFlash:Fire(F_L)
What do you mean? You just have to move the event handler inside the same script that the coroutine is created in, but you can still fire the event from any other script.