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

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

Asked by 4 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

I have the way I got leader stats: 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

1 answer

Log in to vote
0
Answered by 4 years ago

Here is something to try. Make sure your leaderstats script isn't erroring. Then do this for the local script instead:

while wait() do
    local Plr = game.Players.LocalPlayer
    local stats = Plr:WaitForChild("leaderstats")
    local Strength = stats:WaitForChild("Strength")

    script.Parent.Text = "Strength: " .. Strength.Value
end
0
also you could have formatted the other bit of script to MrCatDoggo 213 — 4y
0
yooo thank you soo much ive been trying for an hour ADAM6O00 4 — 4y
0
np MrCatDoggo 213 — 4y
Ad

Answer this question