Knockback is delayed and jittery

I’m using Body Velocity (I know it’s deprecated) because Linear Velocity is too buggy for my use case. However, I’m experiencing a delay when applying knockback with the last punch, as seen in the video. I’ve already set the network ownership to the server, but the knockback is still jagged and not smooth. I create the Body Velocity on the server.

if EnemyHumanoid then
	EnemyHumanoid:TakeDamage(5)
			
	EnemyHumanoidRootPart:SetNetworkOwner(nil)
			
	local BodyVelocity = Instance.new("BodyVelocity", EnemyHumanoidRootPart)
	BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	BodyVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * 100
						
	Debris:AddItem(BodyVelocity, 0.1)
end

How could I make it smoother?

1 Like

try parenting it after, normally parenting in the instance can cause some latency issues.

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BodyVelocity.Velocity = HumanoidRootPart.CFrame.LookVector * 100
BodyVelocity.Parent = EnemyHumanoidRootPart

I have just tried it and it still have some noticeable delay. I also tried doing the knockback when the animation plays instead of if it reaches the event marker on the animation.

I would try and move to VectorForce, i used it for some combat and it worked pretty good no delays, when using a deprecated instance, things like this are not controllable. There could be other factors of a hidden wait time and such that is not seeable in the code you provided. But its better to go with new instances. I had to use a youtube tutorial to understand VectorForce so do not be afraid to look there as well

I don’t know, If I am doing anything wrong but I still am getting delays maybe it could be because I am doing the knockback on the server.

if EnemyHumanoid then
	EnemyHumanoid:TakeDamage(5)
			
	EnemyHumanoidRootPart:SetNetworkOwner(nil)
			
	local Attachment = Instance.new("Attachment")
	Attachment.Parent = EnemyHumanoidRootPart
			
	local VectorForce = Instance.new("VectorForce")
	VectorForce.Attachment0 = Attachment
	VectorForce.Force = HumanoidRootPart.CFrame.LookVector * 15000
	VectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
	VectorForce.Parent = Attachment
		
	Debris:AddItem(VectorForce, 0.2)
end

I heard that there is something called client replication which replicates effect to the client. However I don’t know, If this applies to knockbacks.

Usually on server, Effects/Animations have a bit of delay, so I would suggest using client for effects/animations.

I just have now tried to add knockback on the client instead of the server, However, the knockback doesn’t work the enemy doesn’t get knocked backed. I added print statements and it goes through each line. It just doesn’t knockback the enemy.

because clients cant interact with other clients. the same way how if i were to interact with your humanoid walkspeed nothing will happen.

Clientside forces applied to a character require a player to be assigned to that character in order to work

Could you elaborate more? I not sure what your trying to say. Sorry.

he meant that when you apply forces (like using BodyVelocity , BodyForce , or VectorForce ) to a character on the client side, the forces will only work if the character is associated with a player. This is because the client needs to know which player the character belongs to in order to properly apply and replicate the forces.

Apply server force only if the character you’re trying to apply force to has no player