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

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

while wait() do local player = game.Players.LocalPlayer script.Parent.Text = "Strength:" ..player:WaitForChild("leaderstats"):FindFirstChild("Strength").Value end This is in a local script and local script in a text label I am trying to put the leaderstats in a gui for my simulator game but its not working its giving me the error:Infinite yield possible on 'Players.Player1:WaitForChild("leaderstats")' please help

2 comments

0

Either leaderstats doesn't exist for a way too long time or you might've spelt it wrong or haven't specified its location well.

0

Its just saying that there can be infinive things that can have the name u wait for

2 answers

Its just saying that there can be infinive things that can have the name u wait for

1 comment

0

i specified it as a child for the player(local player) but it didnt work

First of all, you are constantly defining the local player which can cause performance issues and you are also using an unnecessary loop, try this: JasiuJasiuB is wrong by the way, an infinite yield means an infinite wait not infinite items.

local player = game.Players.LocalPlayer
local stat = player:WaitForChild('leaderstats'):WaitForChild('Strength')
stat.Changed:Connect(function()
script.Parent.Text = "Strength:"..stat.Value
end)

3 comments

0

I don't get it i have the same error?

0

thiss is how i got the leader stats

0

game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local strength = Instance.new("NumberValue") strength.Name = "Strength" strength.Parent = leaderstats

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