I want all my lights to turn on and off if Switch = true Error I get Transparency is not a valid member of BoolValue "Workspace.Construction lights.Light Arrow.Switch"
game.ReplicatedStorage["Light Settings"]["Left Lights"].OnServerEvent:Connect(function() local Switch = script.Parent["Light Arrow"].Switch while true do wait(1) while Switch.Value == true do local ConLights = script.Parent["Light Arrow"] for _, ConLights in ipairs(ConLights:GetChildren()) do ConLights.Transparency = 0 wait(1) ConLights.Transparency = 1 end end end end)
Updated script
game.ReplicatedStorage["Light Settings"]["Left Lights"].OnServerEvent:Connect(function() local Switch = script.Parent.Switch local ConLights = script.Parent["Light Arrow"]:WaitForChild(script.Parent["Light Arrow"].LPart, 12) while Switch.Value == true do task.wait() for _, ConLights in ipairs(script.Parent["Light Arrow"]:GetChildren()) do ConLights.Transparency = 0 wait(1) ConLights.Transparency = 1 end end end)
If you need a screenshot of what the explorer looks like let me know.
As we don't know about the structure of your workspace, it's somewhat hard to identify the exact issue. Though, I have some ideas:
ConLights
variable-name for both script.Parent["Light Arrow"]
and its Child-instances.script.Parent["Light Arrow"]
is a BoolValue
, this can be solved by using :IsA("BasePart")
. Assuming that the BoolValue
is also a child of script.Parent["Light Arrow"]
, using the Error as source, it's probably what's causing the error.while
loops. Even though this isn't necessarily a problem (as far as I know), it is (in my opinion) bad practice.