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

Infinite yield possible on 'Players.Player1:WaitForChild("leaderstats")'?

Asked by 4 years ago

Yeah i have no idea how to script and i was following a tutorial and everything worked out well till i added it to the game so i checked the output log and it said: Infinite yield possible on 'Players.Doodlyooo:WaitForChild("leaderstats")'

I have no idea what to do and this is part of the script

local player = game.Players.LocalPlayer local exp = player:WaitForChild("leaderstats"):WaitForChild("Exp") local axp = player:WaitForChild("leaderstats"):WaitForChild("ExpNeeded")

someone please help ^^ the full script- https://pastebin.com/Zr3ph050

0
its probably because the leaderstats folder isnt parented to the player yet UnitRook -5 — 4y
0
Infinite yield, meaning there is a possibility the script will be on halt waiting for "child" indefinitely. Make sure you know that "leaderstats" will exist in the said directory. Sergio4755 21 — 4y
0
you have not created leaderstats Gameplayer365247v2 1055 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Your error means that the method :WaitForChild() has been waiting for an unusually long period of time, so you get a warning that what you want may not exist.

For you, all you need to do is create the leaderstats. Due to no leaderstats existing, I'll take a guess that Exp and ExpNeed also does not.

Try the below script; place it in ServerScriptService (not a local script):

game.Players.PlayerAdded:Connect(function(Plr)
    local L = Instance.new("Folder", Plr)
    L.Name = "leaderstats"
    local E = Instance.new("NumberValue", Plr.leaderstats)
    E.Name = "Exp"
    local EN = Instance.new("NumberValue", Plr.leaderstats)
    EN.Name = "ExpNeeded"

    L, E, EN = nil, nil, nil
end)
0
Thank you alot =D Doodlyooo 2 — 4y
0
no problem alphawolvess 1784 — 4y
Ad

Answer this question