Strange delay in Combat script

  1. What do you want to achieve? Keep it simple and clear!
    i want to make a clean knockback system with this script

  2. What is the issue? Include screenshots / videos if possible!
    there is a strange delay that happens on the knockback m1 (the fifth one)
    https://i.gyazo.com/0def3fc1da38669f2c0821150392034a.mp4

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried changing the network ownership to server and player, and i still get this delay

hitbox.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name then
			local enemyhum = hit.Parent:FindFirstChild("Humanoid")
			enemyhum:TakeDamage(1)
			hitbox:Destroy()
			weld:Destroy()
			
			local particles = combatstuff.Particles:Clone()
			particles.Parent = hit.Parent.HumanoidRootPart
			particles.CFrame = hit.Parent.HumanoidRootPart.CFrame
			particles.Attachment.circle:Emit(1)
			particles.Attachment.burst:Emit(20)
			debris:AddItem(particles,1)
			
			local function npcRagdoll(num)
				if count == 5 then
					if num == 0 then
						hit.Parent:FindFirstChild("RagdollTrigger").Value = true
						local bv = Instance.new("VectorForce")
						bv.Name = "Bv"
						bv.Parent = hit.Parent:FindFirstChild("HumanoidRootPart")
						bv.ApplyAtCenterOfMass = true
						local atc = Instance.new("Attachment")
						atc.Name = "Atc"
						atc.Parent = hit.Parent:FindFirstChild("HumanoidRootPart")
						atc.CFrame = hit.Parent:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,0,-2)
						bv.Attachment0 = atc
						bv.RelativeTo = rps.VectorForce.RelativeTo
						bv.Force = player.Character.HumanoidRootPart.CFrame.LookVector * 1000
						bv.Force = Vector3.new(bv.Force.X,0,bv.Force.Z)
					end
					if num == 1 then
						hit.Parent:FindFirstChild("RagdollTrigger").Value = false
						hit.Parent.HumanoidRootPart:FindFirstChild("Bv"):Destroy()
						hit.Parent.HumanoidRootPart:FindFirstChild("Atc"):Destroy()
					end
				end
			end

			npcRagdoll(0)
			wait(1)
			npcRagdoll(1)

			
		end
	end)
1 Like

Without testing this. Could the delay be from relying on the touched event? Instead of doing that you could use this instead WorldRoot:GetPartBoundsInBox

no it cant be
cuz my damage and particles fire instantly its only the ragdoll and the vector force that are delayed everything else in the touch event is fine

Now, I’m only a beginner when it comes to scripting so don’t blame me if I end up saying something stupid
Anyway, I believe there’s a typo in Line 2 where it’s ~= instead of =

the “~=” means not equal to the player who attacked the character

Ah ok thanks. Didn’t know :+1:

I would start with prints and see where it gets stuck at.

its not getting stuck its delayed there are no errors

Yes, I know that. You use prints for checking the time delay…