Infinite yield for no reason

For some reason it says infinite yield but the hitbox pops up and it doesn’t do anything

It worked fine before but I tried making punch animation and it broke for no reason

Code:

local punchEvent = script.Parent:WaitForChild("PunchClient"):WaitForChild("PunchEvent")
local debounce = 0


function createHitbox(player,size,duration,transparency)
	local hitbox = Instance.new("Part",player.Character)
	local hrp = player.Character:WaitForChild("HumanoidRootPart")
	hitbox.Name = "Hitbox"
	hitbox.Anchored = false
	hitbox.CanCollide = false
	hitbox.Transparency = transparency
	hitbox.Position = hrp.Position + hrp.CFrame.LookVector
	hitbox.Orientation = hrp.Orientation
	local hitboxWeld = Instance.new("WeldConstraint",player.Character)
	hitboxWeld.Part0 = hitbox
	hitboxWeld.Part1 = hrp
	hitbox.Size = size
	task.wait(duration)
	hitbox:Destroy()
	hitboxWeld:Destroy()
end

punchEvent.OnServerEvent:Connect(function(plr)
	local animator = plr.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
	debounce = 0
	createHitbox(plr,Vector3.new(5, 6, 3),0.5,0)
	local hitbox = plr.Character:WaitForChild("Hitbox")
	hitbox.Touched:Connect(function(otherPart)
		if otherPart.Parent:FindFirstChild("Humanoid") then
			if debounce > 1 then
				debounce += 1
				if debounce == 0 then
					animator:LoadAnimation(8081907737):Play()
				elseif debounce == 1 then
					animator:LoadAnimation(8081909737):Play()
				end
				plr.Character:WaitForChild("HumanoidRootPart").Position = plr.Character:WaitForChild("HumanoidRootPart").Position + plr.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector
				otherPart.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
			local oldWalkspeed = otherPart.Parent:FindFirstChild("Humanoid").WalkSpeed
				otherPart.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
				otherPart.Parent:FindFirstChild("HumanoidRootPart").Position = otherPart.Parent:FindFirstChild("HumanoidRootPart").Position + plr.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector
				task.wait(0.4)
				otherPart.Parent:FindFirstChild("Humanoid").WalkSpeed = oldWalkspeed	
			end
		end
	end)
end)


What’s the infinite yield in relation too? The error message should provide more details.

local rs = game:GetService("ReplicatedStorage")
local punchEvent = rs:WaitForChild("PunchClient"):WaitForChild("PunchEvent")
local debounce = false
local anims = 0

function createHitbox(player,size,duration,transparency)
	local hitbox = Instance.new("Part")
	hitbox.Parent = player.Character
	hitbox.Name = "Hitbox"
	hitbox.Anchored = false
	hitbox.CanCollide = false
	hitbox.Transparency = transparency
	local hrp = player.Character:WaitForChild("HumanoidRootPart")
	hitbox.Position = hrp.Position + hrp.CFrame.LookVector
	hitbox.Orientation = hrp.Orientation
	local hitboxWeld = Instance.new("WeldConstraint")
	hitboxWeld.Parent = player.Character
	hitboxWeld.Name = "HitboxWeld"
	hitboxWeld.Part0 = hitbox
	hitboxWeld.Part1 = hrp
	hitbox.Size = size
	task.wait(duration)
	hitbox:Destroy()
	hitboxWeld:Destroy()
end

punchEvent.OnServerEvent:Connect(function(plr)
	local character = plr.Character
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	local anim = animator:LoadAnimation(8081907737)
	createHitbox(plr,Vector3.new(5, 6, 3),0.5,0)
	local hitbox = character:WaitForChild("Hitbox")
	hitbox.Touched:Connect(function(otherPart)
		if otherPart.Parent:FindFirstChild("Humanoid") then
			local char = otherPart.Parent
			local player = game:GetService("Players"):GetPlayerFromCharacter(char)
			local human = char:WaitForChild("Humanoid")
			local hrp = char:WaitForChild("HumanoidRootPart")
			if debounce then
				return
			end
			debounce = true
			anim:Play()
			hrp.Position += hrp.CFrame.LookVector
			human:TakeDamage(5)
			local oldWalkspeed = human.WalkSpeed
			human.WalkSpeed = 0
			hrp.Position += hrp.CFrame.LookVector
			task.wait(0.5)
			debounce = false
			human.WalkSpeed = oldWalkspeed	
		end
	end)
end)

you only need 1 waitforchild on punchevent

local punchEvent = script.Parent:WaitForChild("PunchClient"):WaitForChild("PunchEvent")

Im sure this might be problem

Nah then it says

PunchClient is not a valid member of ReplicatedStorage "Replicated Storage"

WAIT WHY DID I PUT REPLICATED STORAGE LOL

Ok it worked great but I added a new item and the animations mixed up for no reason?

So like if you used punch then used kick the kick animation would be punch and the punch animation would be kick but if you used kick punch punch it would be punch animation kick animation then punch animation

very confusing ik