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

How do you make a gui when you click it it changes color?

On the scripting tutorial the man said to do this script with a text button with nothing else.This is what he said to do in the script.

button = script.Parent
blue = button.BackgroundColor3
red = Color3.new(1,0,0)
green = Color3.new(0,1,0)

function changeColor()
if button.BackgroundColor3 == blue then
button.BackgroundColor3 = red
elseif button.BackgroundColor3 == red then
button.BackgroundColor3 = green
else
button.BackgroundColor3 = blue
end
end

button.MouseButton1Click:connect(changeC­olor)

3 comments

0

Put the code in the codeblock please.

0

How?

0

Nevermind i found out how

1 answer

button = script.Parent
blue = button.BackgroundColor3
red = Color3.new(1,0,0)
green = Color3.new(0,1,0)
print("Found colors and button")

script.Parent.MouseButton1Click:connect(function changeColor()
print("Player Clicked")
if button.BackgroundColor3 == blue then
button.BackgroundColor3 = red
print("Button is now red")
elseif button.BackgroundColor3 == red then
button.BackgroundColor3 = green
print("Button is now green")
else
button.BackgroundColor3 = blue
print("Button is blue")
end
end)

I believe this should work now. I added a few prints.. Just to see what the output is.. If you can test it and see if it works now.. That would be great :D

2 comments

0

Lomo? Does this need to be in a local script?

0

This should be a local script inside the button you want to have it change the color of.

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