I'm trying to do a test for later usage, it is about toggles. This is what I plan to do: When I click on a brick, it toggles between two different colors.
Here it is:
Trigger = script.Parent:WaitForChild('Switch').Trigger Toggle = false Trigger.MouseButton1Click:connect(function() if Toggle == false then Trigger.BrickColor = BrickColor.Red() Toggle = true else Trigger.BrickColor = BrickColor.Green() Toggle = false end end)
It seems not to work... I have tried a lot of versions, which none of them worked, could anyone help me find the real, the functioning one, please ?
Here, let's try the following:
Trigger = script.Parent:WaitForChild('Switch').Trigger Toggle = false Trigger.MouseButton1Click:connect(function() if Toggle == false then --Your problem is here. It's not BrickColor.Red(), it's BrickColor.new("Red"). But Red doesn't exist, so what you would want is BrickColor.new("Really red"): A red variant, pretty similar to the original one. Trigger.BrickColor = BrickColor.new("Really red") Toggle = true else --Your problem is ALSO here. It's not BrickColor.Green(), it's BrickColor.new("Green"). But, once more, Green doesn't exist, so what you would want is BrickColor.new("Dark green"): A green variant, pretty similar to the original one. Trigger.BrickColor = BrickColor.new("Dark green") Toggle = false end end)
If this works, please mark as the solution!
As always, good scripting!
Hope this resolves your issue.
Trigger = script.Parent:WaitForChild('Switch').Trigger Toggle = false Trigger.MouseButton1Click:connect(function(OnClicked) if Toggle == false then Trigger.BrickColor = BrickColor.new("Really red") Toggle = true elseif Toggle == true then Trigger.BrickColor = BrickColor.new("Bright green") Toggle = false end end)
I managed to find and fix it now, I appreciate that you guys wanted to help me, but none of the answers you gave me were correct...
Boy = script.Parent Toggle = true function OnClicked() if Toggle == true then Boy.BrickColor = BrickColor.new("Bright green") Toggle = false else if Toggle == false then Boy.BrickColor = BrickColor.new("Bright red") Toggle = true end end end Boy.ClickDetector.MouseClick:connect(OnClicked)