This is my leaderstats:
local function onPlayerJoin(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = 0 cash.Parent = leaderstats end -- Run onPlayerJoin when the PlayerAdded event fires game.Players.PlayerAdded:Connect(onPlayerJoin)
This is the script I am getting the error on (placed in starter character scripts):
wait(1) local playerModel = script.Parent local player = game.Players:GetPlayerFromCharacter(playerModel) player:WaitForChild("leaderstats") player.leaderstats:WaitForChild("cash") local cash = player.leaderstats.cash while true do wait(5) cash.Value = cash.Value + 100 end
I get the error in the line where it says 'player.leaderstats:WaitForChild("cash") ' The error says that there is Infinite yield possible on 'Players.pinkcust2vids.leaderstats:WaitForChild("cash")' How can I fix this? Thanks in advance :)!