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

When I try to change the color it comes out differently than what I put is as?

Asked by
popeeyy 493 Moderation Voter
7 years ago

So I have this local script in StarterGui and it will change the text color to Some black instead of this blue I defined. How do I fix it so it's blue and is visibly changed?

StarterGui:

script.Parent.MouseButton1Click:connect(function()

local gui= game.Players.LocalPlayer.Character.Rank
    gui.Frame.Name1.TextColor3 = Color3.new(85, 170, 255)

    gui.Frame.TextLabel.TextColor3 = Color3.new(85, 170, 255)

end)

2 answers

Log in to vote
0
Answered by 7 years ago

You need to divide it by /255 in order for it to work, or you can do Color3.fromRGB.


script.Parent.MouseButton1Click:connect(function() local gui= game.Players.LocalPlayer.Character.Rank gui.Frame.Name1.TextColor3 = Color3.new(85/255, 170/255, 255/255) gui.Frame.TextLabel.TextColor3 = Color3.new(85/255, 170/255, 255/255) end)
0
Why? This is the whole reason Color3.fromRGB exists. hiimgoodpack 2009 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago

This looks perfectly fine and should work properly, but I would advise you to add a :WaitForChild() function on the local gui, like this;

script.Parent.MouseButton1Click:Connect(function()
    local gui = game.Players.LocalPlayer.Character:WaitForChild("Rank")
    --and so on...
end)
0
I did, still nope. popeeyy 493 — 7y
0
Good tip, but not the "problem". If the player clicked the GUI then they have loaded in, and chances are so has whatever else. Even if it hadn't, the event would simply fire and error until it existed. The code wouldn't break. Goulstem 8144 — 7y

Answer this question