Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make it change color when you keep clicking?

Asked by 7 years ago

I want the color to change to BrickColor.new(1025) when you continue clicking it and if you click it again then it returns to BrickColor.new(1028). In other words, I want it to repeat the same color pattern. This is what I have so far:

game.Workspace.Tutu1.MyClickDetectorEvent.OnServerEvent:Connect(function()
    script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1028)
end)

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago

You can create an extra value to check which value you'd want the brick color to go to, or you can read out the brick color, and change it acordingly.

I'd suggest to use the first method like so:

local ColorPick = false
game.Workspace.Tutu1.MyClickDetectorEvent.OnServerEvent:Connect(function()
    if ColorPick then
        script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1025)
    else
        script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1028)
    end
    ColorPick = not ColorPick
end)

Basicly, I create the value ColorPick to deside which color the script has to choose. After the color changes, the script will set the colorPick value to either false or true, depending on what it was before.

Ad

Answer this question