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

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

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

✓ Accepted answer

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)

1 comment

0

Why? This is the whole reason Color3.fromRGB exists.

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)

2 comments

0

I did, still nope.

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.

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