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

How do i change TextColor3 with FE on?

Asked by 7 years ago
Edited 7 years ago

Hello, I have the Problem that when i try to change the TextColor3 of an TextLabel via a Script in the ServerScriptService the Color does not (to the right Color Code) change.

game.ReplicatedStorage.Remotes.GR.OnServerEvent:connect(function(player)
    game.ReplicatedStorage.StatsHolder:WaitForChild(player.Name):WaitForChild("Ready")
    game.ReplicatedStorage.StatsHolder:FindFirstChild(player.Name).Ready.Value = true
    game.StarterGui.Ready.Frame:FindFirstChild(player.Name).TextColor3 = Color3.new(0, 255, 0)
end)

The Color Code i get out of this is 0, 65025, 0

Has anyone here had the same Problem? and how did you fix it?

0
Try to use .fromRGB instead of .new at line 4. iRexBot 147 — 7y
0
Thx for that idea iRexBot, but while the Color Code does now get changed to the right Value it does still not show up in the Gui :/ drkater 7 — 7y

2 answers

Log in to vote
1
Answered by
Asceylos 562 Moderation Voter
7 years ago

The main problem is that when FE is enabled, server scripts can't access the PlayerGui. You need to add remoteevents and then use FireClient()

Ad
Log in to vote
0
Answered by
luadotorg 194
7 years ago
Edited 7 years ago

Well, for FE your scripts will require server handling.

I've encountered the flaw in your code and I'll explain it to you.

There is one thing on roblox called floats, which Lua kind of has built-in with the variable type. Floats go from 0 to 1, meaning they will never pass above 1.

A Color3 consists of three floats, R, G, B (Color3.new(float, float, float)). There is a simple solution for this, which is dividing each int (1-255) by 255.

However, in your code's case, you can simply put 255 as 1, as 255/255 = 1.

game.ReplicatedStorage.Remotes.GR.OnServerEvent:connect(function(player)
    game.ReplicatedStorage.StatsHolder:WaitForChild(player.Name):WaitForChild("Ready")
    game.ReplicatedStorage.StatsHolder:FindFirstChild(player.Name).Ready.Value = true
    game.StarterGui.Ready.Frame:FindFirstChild(player.Name).TextColor3 = Color3.new(0, 1, 0)
end)

Also, you've got another issue. game.StarterGui.Ready.Frame:FindFirstChild(player.Name) I'm not sure this is what you wanted; could you please comment what's under StarterGui and it's descendants?

You should be doing player.PlayerGui.Ready.Frame.

Hope this helps you!

Answer this question