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

Trying to change the color of a GUI when clicked, it errors?

p = game.Players.LocalPlayer

function OnClick()
if p.PlayerGui["Transform_Human"].Transformer.BackgroundColor3 == {255,255,255} then	
p.PlayerGui["Transform_Human"].Transformer.BackgroundColor3 = Color3.fromRGB(245,245,245)
p.PlayerGui["Transform_Human"].Transformer.BorderColor3 = Color3.fromRGB(245,245,245)	

elseif p.PlayerGui["Transform_Human"].Transformer.BackgroundColor3 == {245,245,245}	then
p.PlayerGui["Transform_Human"].Transformer.BackgroundColor3 = Color3.fromRGB(255,255,255)
p.PlayerGui["Transform_Human"].Transformer.BorderColor3 = Color3.fromRGB(255,255,255)
	
end	
end
script.Parent.MouseButton1Click:connect(OnClick)

And yes, I have yet to see anything in output.

1 comment

0

Couldn't you just say; Transformer.BackgroundColor = Medium red?

1 answer

✓ Accepted answer

Here try this

p = game.Players.LocalPlayer

function OnClick()
	if p.PlayerGui.Transform_Human.Transformer.BackgroundColor3 == Color3.new(255/255, 255/255, 255/255) then   
		p.PlayerGui.Transform_Human.Transformer.BackgroundColor3 = Color3.new(245/555, 245/255, 245/255)
		p.PlayerGui.Transform_Human.Transformer.BorderColor3 = Color3.new(245/255, 245/255, 245/255)  
	elseif p.PlayerGui.Transform_Human.Transformer.BackgroundColor3 == Color3.new(245/255, 245/255, 245/255) then
		p.PlayerGui.Transform_Human.Transformer.BackgroundColor3 = Color3.new(255/255, 255/255, 255/255)
		p.PlayerGui.Transform_Human.Transformer.BorderColor3 = Color3.new(255/255, 255/255, 255/255)
	end
end
script.Parent.MouseButton1Click:connect(OnClick)

Basically what you did what you made and if statement checking if the color was {255, 255, 255}

but when you do that you have to do this first Color3.new(255/255, 255/255, 255/255)

I cleaned your script up a bit it should work now

1 comment

0

Thanks! It did work, and I would never have guessed that method.

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