While loop? what's that for...
Your script probably stopped because while true do loop without any slow downs will cause script exhausting. You don't need it there as it is only enough to connect the function once and it will fire every time the tool is activated. So:
local tool = script.Parent
tool.Activated:Connect(function()
tool.Handle.BrickColor = BrickColor.new("Bright blue")
end)
Right but... red and blue every time it's clicked? Well, for that all you need is a variable to check if the tool color is red or blue.:
local tool = script.Parent
local currentColor = BrickColor.new("Bright Blue")
tool.Activated:Connect(function()
tool.Handle.BrickColor = currentColor
end)
Now the current color is made but here is how you change it to red and blue and red and...
local tool = script.Parent
local blue = BrickColor.new("Bright Blue")
local red = BrickColor.new("Bright Red")
local currentColor = blue
tool.Activated:Connect(function()
currentColor = (currentColor == blue and red) or blue
tool.Handle.BrickColor = currentColor
end)
You should modifty it a bit as i am not currently in studio so the code may not be the best.
Here is how line 9 works:
currentColor = (currentColor == blue and red) or blue
So first it checks if the current is Blue and if it is blue then by using and statement it switches to next value which is red, but if it is NOT blue then it uses the or statement to switch the color to blue.
About 'AND' and 'OR'
3 comments
oh right, this one is better
Thx!
your code works, thx