Hi! I’m doing something wrong? I can’t figure out what’s happening, everything is going fine until something happens
while true do
local players = game.Players:GetChildren()
for i, plr in pairs(players) do
local leaderstats = plr:FindFirstChild("leaderstats")
if leaderstats then
leaderstats:WaitForChild("TotalCoins",1).Value = ab:ab(game.ServerStorage.Data[plr.Name].Coins.Value)
leaderstats:WaitForChild("Kills",1).Value = ab:ab(game.ServerStorage.Data[plr.Name].Kills.Value)
end
end
wait(0.5)
while true do
local players = game.Players:GetPlayers()
for i, plr in pairs(players) do
local leaderstats = plr:WaitForChild("leaderstats")
if leaderstats then
leaderstats:WaitForChild("TotalCoins").Value = ab:ab(game.ServerStorage.Data[plr.Name].Coins.Value)
leaderstats:WaitForChild("Kills").Value = ab:ab(game.ServerStorage.Data[plr.Name].Kills.Value)
end
end
wait(0.5)
end
You shouldn’t be using “GetChildren” for players, and you shoudl be using waitforchild with leaderstats. If the server is running for a long time, it may not see those instances immedaitly.