Help with color changing overhead textlabel when reaching specific amount of stats

So I want the overhead textcolor3 to be any color when it reaches a specific amount of value.

Here’s what I tried so far, which didn’t work:

if game.Players.player.leaderstats.Time == 50 then
	game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Clone OverHead").TimeGui.TextLabel.TextColor3 = Color3.new(0, 255, 0)
end

can someone please help?

1 Like

You have to check for the value. Your referencing an instance

if game.Players.player.leaderstats.Time.Value == 50 then
	game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Clone OverHead").TimeGui.TextLabel.TextColor3 = Color3.new(0, 255, 0)
end

Assuming that time is a Value instance then this should work.

2 Likes

What r u trying to say, what do i do. and yes, ‘time’ is the stats.

didnt work btw the script u sent

Did it produce an error? Can you show me where the GUI is in the explorer?

let me re-test and check for errors

image

Also what type of script is this? Local or Player?
What i mean is that when you do this:

game.Players.player.leaderstats.Time

You are referencing an instance which is time. Basically think of time like an object
Time is not equal to 50, the value inside it is.

script in serverscriptservice :confused:

Use LocalPlayer if its a local script.

where should i place the local script?

Well you can use replicated storage

what script type though, local or module?

You can still use your old server script in serverscriptservice, but you need a reference to the player so I would use the Players.PlayerAdded event to get it.

1 Like

Also if your using a server script then here is the code

local player

game.Players.PlayerAdded:Connect(function(playerAdded)
  player = playerAdded
end)

if player.leaderstats.Time == 50 then
	game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Clone OverHead").TimeGui.TextLabel.TextColor3 = Color3.new(0, 255, 0)
end

i guess you can tell me where to place the script, what script (module, local, normal)

This is if its a server script: the one i just sent. Put it in server script service

Hold up do this instead



game.Players.PlayerAdded:Connect(function(player)
  if player.leaderstats.Time == 50 then
	game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Clone OverHead").TimeGui.TextLabel.TextColor3 = Color3.new(0, 255, 0)
  end
end)