Does "Infinite yield possible on" is Error?

so i make a LocalScript and Test game it show

Infinite yield possible on ‘Workspace.FlingPart:WaitForChild(“Humanoid”)’
image

I think it not a Big deal but does it really make LocalScript Useless? and that why Mutiplayer Can Part Disappear too?


Footage Very Lag Ngl

Script:

local FlingPart = workspace:WaitForChild("FlingPart")
FlingPart.Touched:Connect(function(otherPart)
	local character = otherPart.Parent
	if character:IsA("Model") and character:FindFirstChild("Humanoid") then
		local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
		if humanoidRootPart then
			local oldPosition = humanoidRootPart.Position
			FlingPart.Position = Vector3.new(-94.794, -4.237, 407.822)
			print(oldPosition)
		end
	end    
end)

now i don’t know how i can Fix it?

No it’s not an error, I used to make that mistake too in the past. It’s a warning that appears if WaitForChild fails to find the instance it’s looking for after 5 seconds pass(and only if you don’t pass in the second parameter). However, after the warning appears, the WaitForChild function will still yield your code until it finds the instance(so it looks forever until it finds it). It’s possible for the warning to appear even tho the script ends up running normally(for example, if there’s lag).

1 Like

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