Knockback not working correctly

  1. What do you want to achieve? Keep it simple and clear!

Hi, I’m trying to script knockback for a fighting game. How the script works is pretty simple:
After getting hit humanoid, the network ownership of it is given to the server, which checks for the Mass of its model, and applies knockback.

  1. What is the issue? Include screenshots / videos if possible!

The knockback works correctly most of the times, the only issue is that, when you apply the knockback while standing on your victim’s head, the force applied is way to high. (I have no idea why the testers tried to do this :skull: ).

Video:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to set the humanoid’s state to physics, and tried to cap the velocity. I’ve also searched on the devHub but can’t find anything related to knockback with assemblyvelocity.

Here’s my code:

local DealDamageKB = function(self, damage, Hum : Humanoid, Knockback, cframe)
	local force = cframe.LookVector * Knockback
	local mass = self.Character.PrimaryPart.AssemblyMass

	local RootPart = Hum.RootPart
	local Player = game.Players:FindFirstChild(Hum.Parent.Name) or false
	
	RootPart:SetNetworkOwner(nil)

	if RootPart.AssemblyLinearVelocity.Y > 0.9 then
		print("Capped KB")
		force = force * 0.6 -- 0.676196024591872
	end

	Hum:TakeDamage(damage)
	
	Hum:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
	
	RootPart.AssemblyLinearVelocity = Vector3.new(0,0,0)
	RootPart.AssemblyLinearVelocity = cframe.LookVector * mass * Knockback
	
	if Player then RootPart:SetNetworkOwner(Player) end
	coroutine.wrap(StunModule.Stun)(Hum, self.Stun)
end

Thanks to everyone willing to help me.

I think the problem is that the player is riding the dummy during its knockback, which then causes it to trip and become unstable. If you disable collisions between characters, that should solve the problem. You may also want to disable certain humanoid states to prevent characters from falling over at all.

What humanoid states do i need to disable to make it unable to fall over? I need the character collisions, i’d rather not disable them

FallingDown, Ragdoll, and Physics are the ones you’re looking for.

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