Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

3 comments

0

its probably because the leaderstats folder isnt parented to the player yet

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.

0

you have not created leaderstats

1 answer

✓ Accepted answer

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)

2 comments

0

Thank you alot =D

0

no problem

This discussion is preserved as it was. New answers, comments, and votes are closed.