I’m currently making a prison and I’m currently stuck since I am wanting to make a Lockdown system for the lights and will turn red when a ClickDetector is pressed. I have the button stuff down but since my Lights are in a folder. (Organization) I don’t know how to make it so those are all able to change color…
local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
function onMouseClick()
end
clickDetector.MouseClick:connect(onMouseClick)
local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
local lights= ... -- reference to Lights folder
function onMouseClick()
--- sure lights folder only have light
for k, light in pairs(lights:getChildren()) do
wait()
light.Color= Color3.fromRGB(255,0,0)
end
end
clickDetector.MouseClick:connect(onMouseClick)
GetChildren() will return a table contain all children in it
local LockdownButton = script.Parent
local clickDetector = LockdownButton.ClickDetector
local lights = game.Workspace.Lights.Part
function onMouseClick()
for k, light in pairs(lights:getChildren()) do
wait()
light.Color= Color3.fromRGB(255,0,0)
end
end
clickDetector.MouseClick:connect(onMouseClick)
And if I do
game.Workspace.Lights
It doesn’t get the children of the parts (The Lights), instead it just gets the parts.