Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Won't My Rank Gui Update When a Player Rejoins the Game?

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!

1 answer

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.

2 comments

0

Oh no it didnt include the top two lines. Just copy this and put it before everything else function onTouched(player) local playClone = game.ServerStorage["RankGUI"]:Clone() local gui = game:GetService("ServerStorage"):WaitForChild("RankGUI") local groupId = 3603734

0

So when a player touches the spawn plate, they will get the rank? I tried that right before I asked this question Lol.

This discussion is preserved as it was. New answers, comments, and votes are closed.