Heya, im making a healthbar and i get this warning/error message.
Infinite yield possible on WaitForChild()
Here is the code(this is not all of it, its too big)
if plr:FindFirstChild("Badge") then
stats.RobotName.TextColor3 = plr.Badge.BadgeColor.Value
end
if plr:FindFirstChild("_nickname") == nil then
stats.RobotName.Text = plr.Name
else
stats.RobotName.Text = plr["_nickname"].Value
stats.RobotName.TextColor3 = Color3.new(1,1,1)
end
stats.HP.Text.Text = "HP "..char.Humanoid.Health.."/"..char.Humanoid.MaxHealth
stats.HP.Bar.Size = UDim2.new(char.Humanoid.Health/char.Humanoid.MaxHealth,0,1,0)
stats.PlayerToHideFrom = plr
stats.Parent = char.Head
local function Yes()
if stats:FindFirstChild("HP") and char:FindFirstChild("Humanoid") then
stats.HP.Text.Text = "HP "..char.Humanoid.Health.."/"..char.Humanoid.MaxHealth
stats.HP.Bar.Size = UDim2.new(char.Humanoid.Health/char.Humanoid.MaxHealth,0,1,0)
end
if char:FindFirstChild("KR") then
if char.KR.Value > 0 then
stats.HP.Text.TextColor3 = Color3.new(1,0,1)
else
stats.HP.Text.TextColor3 = Color3.new(1,1,1)
end
stats.HP.Bar.KR.Size = UDim2.new(char.KR.Value/char.Humanoid.Health,0,1,0)
stats.HP.Bar.KR.Position = UDim2.new(1-char.KR.Value/char.Humanoid.Health,0,0,0)
else
stats:WaitForChild('HP').Text.TextColor3 = Color3.new(1,1,1)--This is were the error message happened
end
end
char.Humanoid.Changed:Connect(Yes)
char:WaitForChild("KR").Changed:Connect(Yes)
if plr.LOVE.Value < 20 then
plr.Character.Humanoid.MaxHealth = (20 + (4*(plr.LOVE.Value-1))) + SelectedArmor.Value.HPBonus.Value
plr.Character.Humanoid.Health = (20 + (4*(plr.LOVE.Value-1))) + SelectedArmor.Value.HPBonus.Value
elseif plr.LOVE.Value >= 20 then
plr.Character.Humanoid.MaxHealth = (100 + (5*(plr.LOVE.Value-20))) + SelectedArmor.Value.HPBonus.Value
plr.Character.Humanoid.Health = (100 + (5*(plr.LOVE.Value-20))) + SelectedArmor.Value.HPBonus.Value
end