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 3 years ago

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

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. rabbi99 714 — 3y
0
Its just saying that there can be infinive things that can have the name u wait for JasiuJasiuB 13 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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

0
i specified it as a child for the player(local player) but it didnt work ADAM6O00 4 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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)
0
I don't get it i have the same error? ADAM6O00 4 — 3y
0
thiss is how i got the leader stats ADAM6O00 4 — 3y
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 ADAM6O00 4 — 3y

Answer this question