[SOLVED] Infinite Yield possible warning, How do I fix it?

I made this script and I’m getting Infinite Yield possible and I don’t understand why, the location of the object is correctly.

Console warning

1

Where the Script is located “Races”

2

My code

local char = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local PlayerData = player:WaitForChild('PlayerData').PlayerStats
local RaceValue = PlayerData.Race
local HornsVisible = player:WaitForChild("Clothes3D").Horns
if RaceValue.Value == "Human" or RaceValue.Value == "Slayer" then
	HornsVisible.InLips.Transparency = 1
	HornsVisible.InLips2.Transparency = 1
elseif RaceValue.Value == "Demon" or RaceValue.Value == "Hybrid" then
	HornsVisible.InLips.Transparency = 0
	HornsVisible.InLips2.Transparency = 0
end

This means that “Clothes3D” couldn’t be found in the player in a certain timeframe and so it throws an Infinite Yield error telling you that, that line of code is gonna stop (yield) the rest of your code

Also, why don’t you use game.Players.LocalPlayer? You don’t have to, I just kinda noticed that

Hello, and how could I fix it? because that line is where my object is placed.

Could you show the hierarchy of your player while play testing?

Yeah here is.

1

I was kinda suspecting that you mixed up the player and the character so well I guess I was right.

What you’re showing me is the character which is always located in Workspace. On the other hand, the player is always in Players (the service)

But basically just change it to this:

character:WaitForChild("Clothes3D")

Since that folder is in the character

I changed it.

2

Maybe add a WaitForChild for horns too?

Yeah it works correctly now thanks you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.