I have a script in my game (in ServerScriptStorage) that gives workers their name and rank above their head.
The problem is that if the player's rank had been changed while the game was running, the rank will only update on new servers.
Here is the script:
local gui = game:GetService("ServerStorage"):WaitForChild("RankGUI") local groupId = 3603734 game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local clone = gui:Clone() clone.TextLabel.Text = (""..player.Name.." | "..player:GetRoleInGroup(groupId).. "") clone.Parent = game.Workspace:WaitForChild(player.Name).Head end) end)
If you have any questions, just comment below!
Thanks!
I had a similar thing happening to me, so I decided to put a script in the spawn locations that makes it so when you touch the spawn point then it puts the gui into the player, or players. Here's the code tell me if it works or if you mean something different?
function onTouched(player)
local playClone = game.ServerStorage["RankGUI"]:Clone() local gui = game:GetService("ServerStorage"):WaitForChild("RankGUI") local groupId = 3603734
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) local clone = gui:Clone() clone.TextLabel.Text = (""..player.Name.." | "..player:GetRoleInGroup(groupId).. "") clone.Parent = game.Workspace:WaitForChild(player.Name).Head end) end)
if player then playClone.Parent = player.PlayerGui
end end
game.Players.PlayerAdded:connect(onTouched)
Feel free to change this.