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

What's wrong with this color script?

Asked by
Sam4550 42
10 years ago
script.Parent.MouseButton1Click:connect(function()
    if script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 == Color3.new(0, 255, 0)
        then do script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 = Color3.new (255, 0, 0)
        script.Parent.TextColor3 = Color3.new (255, 0, 0)
        end
    elseif script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 == Color3.new(255, 0, 0)
        then do script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 = Color3.new (0, 255, 0)
        script.Parent.TextColor3 = Color3.new (255, 170, 0)
        end
    end
end)

I can tell you for a fact that the ".Parent."s here are fine. It's an issue with the color.

I want to check to see if BackgroundColor3 is red or green and then change it to the opposite.

1 answer

Log in to vote
0
Answered by
wazap 100
10 years ago
script.Parent.MouseButton1Click:connect(function()
    if script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 == Color3.new(0, 255/255, 0)
        then do script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 = Color3.new (255/255, 0, 0)
        script.Parent.TextColor3 = Color3.new (255/255, 0, 0)
        end
    elseif script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 == Color3.new(255/255, 0, 0)
        then do script.Parent.Parent.Parent.Parent.Armrest.GUI.Crew.BackgroundColor3 = Color3.new (0, 255/255, 0)
        script.Parent.TextColor3 = Color3.new (255/255, 170/255, 0)
        end
    end
end)

You need to divide all the color stuff by 255

0
This still would not work HexC3D 830 — 10y
1
@hex yes it would. do-end is a valid form of scripting. k wazap 100 — 10y
0
@wazap Not exactly necessary but definitely would work Ekkoh 635 — 10y
Ad

Answer this question