game.Players.PlayerAdded:connect(function(player) local stats = player:findFirstChild("leaderstats") local rank = stats:findFirstChild("Rank") function Update() rank.Value = player:GetRoleInGroup(964666) while true do wait(5) Update() end end end)
It is supposed to update a player's rank when a player joins the server every 5 seconds. "Rank" is a StringValue in leaderstats.
I am not entirely sure what the problem is.
TIP: format your code better, E.G:
eventName:connect(function() if blah then function ye() -- code end end end)
The problem is that you cannot fire a function inside the same function, change your code to this:
game.Players.PlayerAdded:connect(function(player) local stats = player:findFirstChild("leaderstats") local rank = stats:findFirstChild("Rank") function Update() rank.Value = player:GetRoleInGroup(964666) end while true do wait(5) Update() end end)
EDIT:
It does not wait for stats to exist, so add a new line under Line 1:
repeat wait() until player.leaderstats
Hope I helped :)
~TDP