LinearVelocity Glitches NPC in Knockback System

Hey guys, my linear velocity system is not working as it should. I am trying to create a knockback / retreat jump thing for my enemy NPC. This is whats happening:

Client-SIde:

Image from Gyazo

As you can see, its super glitchy and the npc teleports.

Server-Side:

Image from Gyazo

This is what its supposed to look like.

This is how my system works:

I have a - Functions ModuleScript

function module.CreateForce(Time, ForceName, ForceLocation, ForceVelocity, Looped, F, Direction)
	local Force = Instance.new("LinearVelocity", ForceLocation)
	local Attach = Instance.new("Attachment", ForceLocation)
	Attach.Orientation = Vector3.new(0,Direction,0)
	Force.Attachment0 = Attach
	Force.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
	Force.MaxForce = F
	
	Force.LineVelocity = ForceVelocity
	Force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
	Force.Name = ForceName

	debris:AddItem(Attach, Time)
	debris:AddItem(Force, Time)
end

And i call it in this Server Script:

Functions.CreateForce(.1, "SelfForce", HRP, 100, false, 5500, Vector)

The LinearVelocity is created on the server yet the Lag is still there on the client. Why?

Setting the NetworkOwner to the server might fix this.

model:SetNetworkOwner(nil)
1 Like

I have that already!

for i,v in ipairs(enemy:GetDescendants()) do
	if v:IsA("BasePart") and v:CanSetNetworkOwnership() == true then
	v:SetNetworkOwner(nil)
	end
	if v:IsA("BasePart") then
		v.Massless = true
	end 
end

hi, im working on my game and i got the same exact problem, did u find a way to fix it?

I’m not sure if that’ll work. As I understand it, you only need to set the network owner on the primary part, HumanoidRootPart.

Try setting the NetworkOwner, as @WhiteOut_RBLX has suggested. Although, there is no SetNetworkOwner function for a Model class, so you’ll have to set a primary part (if you don’t have one already) and call SetNetworkOwner with nil.

Should be noted, in the case you have a local script doing the knockback, that you’ll have to make it server-sided, in order for it to work with the suggested solution.

1 Like

it helped a bit but player still laggs a bit https://gyazo.com/c994f562b2436cd279451c47a17a2903
here is my code

	local att = Instance.new("Attachment")
	att.Parent = humRP
	Debris:AddItem(att,2)
	
	humRP:SetNetworkOwner(nil)
	
	local LinearVelocity = script:WaitForChild("LinearVelocity"):Clone()
	LinearVelocity.VectorVelocity = humRP.CFrame.LookVector * TacklePower * getMass(char)
	LinearVelocity.Attachment0 = att
	LinearVelocity.Parent = humRP
	LinearVelocity.Enabled = true
	Debris:AddItem(LinearVelocity,.5)

Right. It may still lag, perhaps you could try to optimise your script a little, to reduce the delay? Not sure really. Another note, you’ll only need to set the network owner to nil once, no need to do it every time.

1 Like

ok ill try, thanks for the response

1 Like

bro i just decided to stick with BodyVelocity. It works a lot better and doesn’t lag at all.

damn ill try it beacuse players still laggs a lot, but isnt it derpecated tho?

yea but it works better than linear velocity