Hello.
I'm trying to make a script that sets a player's leaderstats to their group rank. It does that, but it doesn't update unless every player leaves the game.
function joined(plr)
local ls = Instance.new("Model")
ls.Name = "leaderstats"
ls.Parent = plr
local st = Instance.new("StringValue")
st.Parent = ls
st.Name = "Rank"
plr.CharacterAdded:Connect(function(char)
local plrname = char.Name
local rank = game.Players[plrname]:GetRoleInGroup(3693179)
if rank ~= 0 then
plr.leaderstats.Rank.Value = rank
else
plr.leaderstats.Rank.Value = "Guest"
end
end)
end
game.Players.PlayerAdded:Connect(joined)
I've been trying to make this for a while now, but I can't seem to get it right.
Help would be appreciated.
Thanks

1 comment
I tried to get it to update when the player resets