For loops really hate me.
This script I made is supposed to make all the alarms in my place play at once when the OilPressure's value is greater than 3499. NLA is a model holding all the alarms, which are all named NauticalLightAlarm.
- Workspace
- NLA
- NauticalLightAlarm
- Light
- PointLight
- Light
- NauticalLightAlarm
- NauticalLightAlarm
- NLA
The problem is that the generic for loop is only making the alarms play one by one in a sequence rather than all at once. When I use a normal for loop, only one alarm plays. How do I fix it?
gc = game.Workspace.NLA:GetChildren()
while true do
wait(1)
if game.Workspace.Config.OilPressure.Value > 3499 or game.Workspace.Config.GasPressure.Value > 3499 then
on = true
for i,v in pairs(gc) do
if v.Name == "NauticalLightAlarm" then
while on do
v.Light.PointLight.Enabled = true
v.Light.Material = "Neon"
v.Light.BrickColor = BrickColor.new("Really red")
wait(0.75)
v.Light.PointLight.Enabled = false
v.Light.Material = "SmoothPlastic"
v.Light.BrickColor = BrickColor.new("Dark stone grey")
wait(0.75)
end
end
end
end
end

1 comment
Thanks a lot!