Hey everybody, I am very confused. I am writing code controlling a fire alarm system in my game. I made a for loop cycling through the workspace, finding the child named, “Alarm.” Every alarm has the same children, and I am looking for the pointlight, which is supposed to flash on, and off. The problem is that the script only chooses 1 not all the children under that name. I have tried making a value inside each alarm, and putting an if statement to see if the value is in there. I don’t know what to do about this. If you need me to clear up the situation, because it is kinda confusing, please let me know. Thanks!
game.Players.PlayerAdded:Connect(function()
while wait() do
if game.Workspace:FindFirstChild("Fire") then
for _,v in pairs(game.Workspace:GetChildren()) do
if v.Name == "Alarm" and v:IsA("Model") and v:FindFirstChild("alarm") then --v:FindFirstChild("alarm") is for finding that value inside of it for identification.
while wait() do
game.Workspace["Realistic Fire Alarm sound"]:Play()
v:FindFirstChild("Strobe"):FindFirstChild("Light").Enabled = true
v:FindFirstChild("Strobe"):FindFirstChild("Flasher").Enabled = true
wait(1)
v:FindFirstChild("Strobe"):FindFirstChild("Light").Enabled = false
v:FindFirstChild("Strobe"):FindFirstChild("Flasher").Enabled = false
wait(1)
end
end
end
end
end
end)