Hi, I am trying to make a name tag that changes colour according to whatever team they are on. Let’s say they are on the blue team, their name tag would change to the blue colour. Right now I have the main script that kinda manages the name tag to display the Name of the user, their rank in the group, and what team they are on. Inside the text UI for the team part I have managed to make a local script that changes the colour according to whatever team I am on but the only problem is when I go in team test with other people it only let’s me see my name tags colour change. I will show pictures of my explorer and the setup. This is what is in the local script:
local rank = script.Parent
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
rank.TextColor3 = Color3.fromRGB(R,G,B)
Main Script:
local groupID = 13232134
game.Players.PlayerAdded:Connect(function(player)
local groupRank = player:GetRoleInGroup(groupID)
local clone = script.Rank:Clone()
clone.Parent = game.Workspace:WaitForChild(player.Name).Head
clone.Frame.Name1.Text = player.Name
clone.Frame.Rank.Text = groupRank
clone.Frame.Team.Text = player.Team.Name
player.CharacterAdded:Connect(function()
local groupRank = player:GetRoleInGroup(groupID)
local clone = script.Rank:Clone()
clone.Parent = game.Workspace:WaitForChild(player.Name).Head
clone.Frame.Name1.Text = player.Name
clone.Frame.Rank.Text = groupRank
clone.Frame.Team.Text = player.Team.Name
end)
end)
Below is an image of what it looks like and what I mean by I can’t see other peoples change colour.
The local script is named Colour changer and the main one is InsRankHandler. All of this is put in ServerScripService. If anyone can figure out why it isn’t making other peoples name tag change that I can see then I would really appreciate some feedback!
I’m not too good at scripting, but it might be because you tried it in a LocalScript, because with a local script, it only does certain stuff with the player themself, not with others. If I’m correct (probably not tbh), you should try messing around with a normal script and see if some chunks might work in a normal script instead of a local script
local rank = script.Parent
local Player = game.Players.PlayerAdded:Wait()
local Color = Player.Team.TeamColor.Color
local function ChangeTeam()
local R,G,B
R = Color.R * 255
G = Color.G * 255
B = Color.B * 255
rank.TextColor3 = Color3.fromRGB(R,G,B)
end
ChangeTeam()
Player.Team.TeamColor:GetPropertyChangedSignal("Color"):Connect(ChangeTeam)
Hello, the issue is because you are doing the color change on the client-side via LocalScript. Changes made on the client do not replicate to the server therefore other players will not be able to see that change. This is due to a security feature roblox added to prevent exploiters from abusing games.
To fix this, simply create a function in your script that changes the UI Color when the Character reloads or gets added. Here’s an example:
local function ChangeUIColor(Player)
local teamColor = Player.Team.TeamColor.Color;
local R, G, B = Color.R * 255, Color.G * 255, Color.B * 255;
local playerGui = Player:WaitForChild("PlayerGui");
local Rank = Rank.Frame.Rank;
Rank.TextColor3 = Color3.fromRGB(R, G, B);
end;
You can call this with:
ChangeUIColor(Player : Player)
Hope this helps, let me know if there are still issues.
Okay so I am unsure on where you want me to put this and the function call, also I did try to do it but no matter how I did it the words color were highlighted and the player in the function call were highlighted.
So I have changed the local script to a regular script and changed the code to:
local rank = script.Parent
local Player = game.Players.PlayerAdded:Wait()
local Color = Player.Team.TeamColor.Color
local R,G,B
R = Color.R * 255
G = Color.G * 255
B = Color.B * 255
rank.TextColor3 = Color3.fromRGB(R,G,B)
which has helped with making the other users name tag change colour, but the only problem now is that if anyone switches teams the colour doesn’t change. So all I need now is to figure out how to make it so when you change teams the colour changes accordingly.
I have 2 regular scripts, the one that holds everything and the one inside the Team textUI, which one does it go and and do I delete anything when I add it in? Also why does the word color highlight when I add it in?