Color Detection Script not working

So basically I’m trying to make a system, that gets the players teamcolor and changes a textlable texcolor to that. Easy enough right? Well, I also have another text label that needs to be the teamcolor but a few shades darker. I have a script that I found on the forum but it doesn’t work.

Script:

-- UI Variables
local text		= script.Parent.PlayerName
local text2		= script.Parent.PlayerName.PlayerNameShadow
local text3		= script.Parent.TeamText
local text4		= script.Parent.TeamText.TeamTextShadow
local PLAYER    = game.Players.LocalPlayer

local Color = PLAYER.Team.TeamColor.Color
local R,G,B

R = Color.R * 255
G = Color.G * 255
B = Color.B * 255



while true do
	wait(.001)
	text2.Text = text.Text
	text4.Text = text3.Text
	text3.TextColor3 = Color3.fromRGB(R,G,B)
end
1 Like

In your script you got the color outside of the loop which meant it only got the color when the script first ran.
Here is a simplified script:

local plr = game.Players.LocalPlayer

plr:GetPropertyChangedSignal("TeamColor"):Connect(function()
	text3.TextColor3 = plr.TeamColor.Color
end)

It should convert to RGB by itself.

1 Like

This isn’t working for me either, also I still need a way to set the text4 to a shade darker than text3.

TeamColor is stored as a BrickColor value whereas color for “TextLabel” instances is stored as a Color3 value.

-- UI Variables
local text		= script.Parent.PlayerName
local text2		= script.Parent.PlayerName.PlayerNameShadow
local text3		= script.Parent.TeamText
local text4		= script.Parent.TeamText.TeamTextShadow
local PLAYER    = game.Players.LocalPlayer

local Color = PLAYER.TeamColor
local R, G, B = math.round(Color.r * 255), math.round(Color.g * 255), math.round(Color.b * 255)

while task.wait() do
	text2.Text = text.Text
	text4.Text = text3.Text
	text3.TextColor3 = Color3.fromRGB(R,G,B)
	text4.TextColor3 = Color3.fromRGB(R-30,G-30,B-30)
end

Is this a server or local script?

Local script since “game.Players.LocalPlayer” is fetched.

I know, I’m just asking if they put it in a server script. Because if they did then that means their script wont work.

I doubt it since it’s managing UI as well & he mentioned an issue with text colors.

1 Like

Yes, it is a local script located within a GUI

I did provide a new script, it should work providing the things outside of the script are placed/working correctly.