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

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

Asked by 10 years ago

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)
0
Put the code in the codeblock please. lomo0987 250 — 10y
0
How? iluvmaths1123 198 — 10y
0
Nevermind i found out how iluvmaths1123 198 — 10y

1 answer

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
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

0
Lomo? Does this need to be in a local script? iluvmaths1123 198 — 10y
0
This should be a local script inside the button you want to have it change the color of. lomo0987 250 — 10y
Ad

Answer this question