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

My local script for a Gui has no errors, but a infinite yield problem, help?

Asked by 7 years ago
Edited 7 years ago

I'm on a wiki lesson on Roblox that makes a custom player info Gui in the top right corner of the screen, but the local script isn't working, and I even plugged in the wiki lesson's local script and that STILL didn't work. The error is this

12:31:06.196 - Infinite yield possible on Players.GreekGodOfMLG.PlayerGui.PlayerHub.PlayerInfo:WaitForChild("Avatar")

I have encountered this error multiple times before when I used WaitForChild, but I'm stumped on how to fix this issue, can you guys help me? Here's my code that I wrote, kind of changed some parts of it to make it more comfortable for me.

--\\ Services/Labels


local Player = game:GetService('Players').LocalPlayer
local PlayerInfo = script.Parent


--\\ Character of player info


PlayerInfo:WaitForChild('Avatar').Image = 'http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=' .. Player.Name
PlayerInfo:WaitForChild('ClientName').Text = Player.Name


--\\ Health function/info


local HealthBar = game:WaitForChild('HealthBar')


Player.CharacterAdded:connect(function(Character)
    local Humanoid = Character:WaitForChild('Humanoid')
    Humanoid.HealthChanged:Connect(function(Health)
        local HealthPercentage = Health / Character.Humanoid.MaxHealth
        HealthBar.Size = UDim2.new(HealthPercentage, 0, 1, 0)
    end)
end)


--//Disabling default health bar


game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)

Hopefully, I explained myself the best I can and my situation.

Here's the lesson I am learning off if it helps or you want to check it out for yourself.

Greek

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

Infinite yield means that it is unable to find "Avatar".

Basically "Avatar" isn't a valid member of "PlayerInfo." :-]

Therefore :WaitForChild() will never end.

In other words, It'll keep waiting for Avatar to be a parent/valid member of PlayerInfo.

0
Intresting, guess I gotta rewrite some code, thanks! GreekGodOfMLG 244 — 7y
Ad

Answer this question