Help with part touch

Hello. I’m having an issue with the Part.Touched.

Issue:

  • when my hitboxes are created and are touching a humanoid, they don’t register right away. I have to keep swinging my sword for it to finally start registering and doing what it needs to.
  • Another weird situation I’m having with this that links with the first problem above, is that they’ll only register right away when I’m really close to the humanoid and swinging my sword. Here’s a video:

    In this video you can see me swinging (hitboxes are clearly touching the parryRig) but nothing happens. I get really close and then they register. Towards the end of the video (the last registering hit) you see it register while I’m not really close to the parryRig. That’s because I was swinging the sword for a while already.

If needed, here’s my LocalScript that is enabled and disabled from AnimationEvents (from a ServerScript). This Local Script creates the 2 hitboxes with all the needed properties. Also holds all the things to do depending on what kind of rig the hitboxes touch; ParryRigh, BlockRig, and NormalRig:

local Hitbox1Clone = createHitboxClone(Hitbox1)
	
	Hitbox1Clone.CFrame = Character.HumanoidRootPart.CFrame + Character.HumanoidRootPart.CFrame.LookVector * Vector3.new(7, 0, 7)

	Hitbox1Clone.Touched:Connect(function(hit)
		local NormalBox = hit.Parent:FindFirstChild("NormalBox")
		local BlockBox = hit.Parent:FindFirstChild("BlockBox")
		local ParryBox = hit.Parent:FindFirstChild("ParryBox")
		if NormalBox and not BlockBox and not ParryBox and hit.Parent ~= script.Parent.Parent and not hitDummies[hit.Parent] then
			print("Hit other humanoid!")
			Hitbox1Clone.Color = Color3.new(1, 0, 1)
			HitHumanoid:FireServer(NormalBox)
			hitDummies[hit.Parent] = true -- Mark this dummy as hit
			--HITTING BLOCK			
		elseif BlockBox and not NormalBox and not ParryBox and hit.Parent ~= script.Parent.Parent and not hitDummies[hit.Parent] then
			Hitbox1Clone.Color = Color3.new(0, 0, 1)
			ClashVFXPlay:FireServer()
			hitDummies[hit.Parent] = true -- Mark this dummy as hit
			print("Hit Block")
			--HITTING PARRY			
		elseif ParryBox and not NormalBox and not BlockBox and hit.Parent ~= script.Parent.Parent and not hitDummies[hit.Parent] then
			Hitbox1Clone.Color = Color3.new(0, 1, 1)
			ParryVFXPlay:FireServer()
			StunAnim:Play()
			Character.Humanoid:TakeDamage(10)
			hitDummies[hit.Parent] = true -- Mark this dummy as hit
			print("Hit Parry")
			--HITTING YOURSELF
		elseif hit.Parent == script.Parent.Parent then
			Hitbox1Clone.CanTouch = true
			print("hit self")
			--HITTING OTHER HITBOX
		elseif hit.Parent == Hitbox1Clone then
			Hitbox1Clone.Color = Color3.new(1, 1, 1)
			Hitbox1Clone.CanTouch = true
			print("Hitbox hit other hitbox")
		end
	end)

Please help! tysm.

1 Like