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?
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()
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!