You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’d like to create a system to where when you press a button multiple alarms come on at once, I’d like to keep the script to where if I added more alarms the script would function without me having to put in a new variable and set it up. -
What is the issue? Include screenshots / videos if possible!
I’ve tried to look far and wide, and I’m stumped. The best I’ve got to is having one siren sound and then the next siren sound. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Multiple variations of scripts, looking on the Dev Forms, and trying to find something in the toolbox.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- My Lua Code
local isSirenOn = false
local clickDetector = script.Parent.Parent.Buttons.Test.ClickDetector
local sirens = script.Parent.Parent.Sirens:GetChildren()
--
function SirenButtonClicked()
if isSirenOn then
for i=1,#sirens do -- Alarm sector
if sirens[i].Name == "Whelen2905" then
isSirenOn = false
sirens[i].Sound.Sound.FedSig.ScriptOn.Enabled = false
sirens[i].Sound.Sound.FedSig.ScriptOff.Enabled = true
end
end
else
for i=1,#sirens do -- Alarm sector
if sirens[i].Name == "Whelen2905" then
isSirenOn = true
sirens[i].Sound.Sound.whelen_dtmf.Playing = true
wait(1.019)
sirens[i].Sound.Sound.whelen_dtmf.Playing = false
sirens[i].Sound.Sound.T4.Playing = true
wait(16.425)
sirens[i].Sound.Sound.T4.Playing = false
sirens[i].Sound.Sound.FedSig.ScriptOn.Enabled = true
sirens[i].Sound.Sound.FedSig.ScriptOff.Enabled = false
end
end
end
end
clickDetector.MouseClick:Connect(SirenButtonClicked)
This code is able to start one siren and then start the other, I took part of this from a free model on the toolbox, and when testing that all of the lights and alarms came on at the same time, yet when trying to achieve the same-thing I get a different output.