Infinte yield possible on :WaitForChild("Humanoid")

You can write your topic however you want, but you need to answer these questions:

What is the issue? It warns me about Infinite yield possible on :WaitForChild(“Humanoid”)

part.Touched:Connect(function(ot)
		local char = ot.Parent
		local Humanoid = ot:WaitForChild("Humanoid")
		if Humanoid then
			print("Humanoid found")
			Humanoid:TakeDamage(math.random(1,100))
		elseif not Humanoid then
			print("Humanoid Not Found")
		end
	end)

It says infinite yield possible on :WaitForChild(“Humanoid”) for some reason. Could you guys help?

im not really a scripter but whenever the infinite yield possible thing appears on my output when scripting it really doesnt do anything, its just a reminder or something, so unless it says it in the error tab then i dont think it really matters

It makes the script stop functioning.

ok let me try the script out for myself and figure out the problem

i fixed it, heres the script:

script.Parent.Touched:Connect(function(ot)
if ot.Parent:FindFirstChild(“Humanoid”) then
print(“Humanoid found”)
ot.Parent.Humanoid:TakeDamage(math.random(1,100))
elseif not ot.Parent.Humanoid then
print(“Humanoid Not Found”)
end
end)

1 Like

the problem was u didnt add findfirstchild(“Humanoid”) and used waitforchild, but instead of using the variable i just typed it out instead

:heart::heart::heart::heart::heart::heart:
It finally worked thank you!

1 Like

(the infinite yield was not an error and it was something different btw)

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