I've created an over head GUI using a billboard GUI, and a TextLabel inside of the billboard GUI. Although when a player is refreshed in game it will not update the group rank if their rank has been changed. The server has to be shutdown in order for their ranks to update. How can this be fixed?
local billboardgui = game:GetService("ServerStorage"):WaitForChild("BillboardGui")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if player:IsInGroup(2597387) then
wait(2)
local clonedgui = billboardgui:Clone()
clonedgui.TextLabel.Text = player:GetRoleInGroup(2597387)
clonedgui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
end
end)
end)

3 comments
You cannot do this as on the server the result is cached. You can get the updated role by sending it to the server from the client, however since the client is sending this information an exploiter can send bad information. The best you can do is kick the player.
So what needs to be done differently in the code then?
I don't know if this would work but you could use https://developer.roblox.com/api-reference/function/GroupService/GetGroupsAsync