while wait(1) do
for _, player in next, game.Players:GetChildren() do
if player.MembershipType == Enum.MembershipType.Premium then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5
end
end
end
In a server script. There is nothing else in the script. Premium members do not receive 5 coins per second. I understand there may be a more efficient way of doing this, but right now I just need it to work.
wait(10)
for _, Plr in pairs(game.Players:GetPlayers()) do
local leaderstats = Plr:WaitForChild("leaderstats")
local Coins = leaderstats:WaitForChild("Coins")
if Plr.MembershipType == Enum.MembershipType.Premium then
Coins.Value += 5
end
end
Use pairs instead, and you might wanna consider waiting a bit longer so that the leaderstats & Coins are able to be properly Parented inside your Player Object
I’m not sure if ‘leaderstats’ would be created on the client to prevent exploiters…? (Also leaderboard won’t work) @JackscarIitt I took your logic for WaitForChild() and the code now works. Thanks!