Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

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 protectiverobos -50 — 6y
0
So when a player touches the spawn plate, they will get the rank? I tried that right before I asked this question Lol. Lama_llama 8 — 6y
Ad

Answer this question