Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix Infinite yield possible? [Solved]

Asked by 4 years ago
Edited 4 years ago

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 :)!

0
Cash is case sensitive, the name is Cash with a capital C, not cash with a lowercase c. Another thing (just a tip) you could do is combine these into one script and just run a while loop to give them their cash when they join. killerbrenden 1537 — 4y
0
So, change line 6 on the StarterCharacterScripts Script to player.leaderstats:WaitForChild("Cash") killerbrenden 1537 — 4y
0
Thanks for the help. It works now! pinkcust2vids 2 — 4y
0
No problem! killerbrenden 1537 — 4y

Answer this question