Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

? Transparency is not a valid member of BoolValue "Workspace.Construction ?

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.

1 answer

✓ Accepted answer

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:

  • You use the same ConLights variable-name for both script.Parent["Light Arrow"] and its Child-instances.
  • It could be that one of the children in 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.
  • Generally speaking, there's also the issue that you use nested while loops. Even though this isn't necessarily a problem (as far as I know), it is (in my opinion) bad practice.

3 comments

0

Thx for your help I finally got the error removed but all the parts in ["Light Arrow"] which is a model within a model I updated my script with the new code

0

If that's the case, you should mark this answer as accepted.

0

ok!! Then New post

This discussion is preserved as it was. New answers, comments, and votes are closed.