Problems with knockback

In our game, the knockback system is very broken, and we don’t know why.

Sometimes, the player is hit multiple times while in the air:

Video

robloxapp-20230128-1748170.wmv (4.2 MB)

Problematic script section:

applyImpulse:FireClient(game.Players:FindFirstChild(hit.Parent.Name), "HumanoidRootPart", (player.Character.HumanoidRootPart.CFrame.LookVector * 1000) + Vector3.new(0, 500, 0))

hit.Parent.Humanoid.Health -= 10

Client Script(Potential problem):

local applyImpulse = game.ReplicatedStorage.ApplyImpulse

applyImpulse.OnClientEvent:Connect(function(part, impulse)
	
	game.Players.LocalPlayer.Character:FindFirstChild(part):ApplyImpulse(impulse)
	
end)

How do we fix this? This is essential to our game.

Thank you!

~ NinjaFactory

You can add a cooldown like this:

if not db then
     db = true
     applyImpulse:FireClient(game.Players:FindFirstChild(hit.Parent.Name), "HumanoidRootPart",(player.Character.HumanoidRootPart.CFrame.LookVector * 1000) + Vector3.new(0, 500, 0))
     hit.Parent.Humanoid.Health -= 10
     task.wait(--put cooldown amt)
     db = false
end
1 Like