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

What's wrong with this color script?

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

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

3 comments

0

This still would not work

1

@hex yes it would. do-end is a valid form of scripting. k

0

@wazap Not exactly necessary but definitely would work

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