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

How do I fix this error?

Asked by
Ortron 27
10 years ago

I've spend ages trying to figure out another error and now I have one that I can't solve.

gui=script.Parent
player=Game.Players.LocalPlayer

function Clicked()
    gui.TextButton.BackgroundColor3=255, 78, 134
    wait(2)
    gui.TextButton.BackgroundColor3=155, 255, 247
end

script.Parent.TextButton.MouseButton1Click:connect(Clicked)

The output shows with this:

13:57:55.385 - Players.Player1.PlayerGui.P.LocalScript:5: bad argument #3 to 'BackgroundColor3' (Color3 expected, got number) 13:57:55.388 - Script 'Players.Player1.PlayerGui.P.LocalScript', Line 5 13:57:55.391 - Stack End 13:57:55.393 - Disconnected event because of exception

2 answers

Log in to vote
1
Answered by 10 years ago

You should do the follow:

-- Change:
gui.TextButton.BackgroundColor3 = 255, 78, 134
wait(2)
gui.TextButton.BackgroundColor3 = 155, 255, 247
-- To:
gui.TextButton.BackgroundColor3 = Color3.new(255, 78, 134)
wait(2)
gui.TextButton.BackgroundColor3 = Color3.new(155, 255, 247)

The BackgroundColor3 property requires a Color3 Value.

Ad
Log in to vote
0
Answered by 10 years ago

You're trying to set the property with numbers, when you need to set it as a Color3 with Color3.new(). Like this:

gui.TextButton.BackgroundColor3=Color3.new(255, 78, 134)

Answer this question