Linear Velocity not working on a local script

Hey, So I’m working on a knockback system using linear velocity on a local script, however it seems like it only works when i set network ownership? why is this the case?

Roblox recently updated linear velocity and to enable it, you need to enable a property in workspace called MoverConstraintRootBehavior, I did this but its still the same.

local script:

local linearVelocity = Instance.new("LinearVelocity")
	local attachment0 = Instance.new("Attachment")
	attachment0.Parent = Torso
	linearVelocity.Parent = Torso
	linearVelocity.Attachment0 = attachment0
	linearVelocity.MaxForce = math.huge
	linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
	linearVelocity.VectorVelocity = direction * Torso.AssemblyMass * knockbackMultiplier

Ok so I take it you are trying to move something with velocity that isnt your character via the client?

Well allow me to tell you that this is a bad idea.
Do NOT give the player network ownership of another character (cause uh thats what it looks like)

Anyhow the reason your script isnt working is due to the fact that the client can only control things with physics and stuff if it has network ownership of said thing, the reason being is that other wise, the client could just add some kind of force to another player and send them into the void, and things would get bad if an exploiter got access to that.

So add the velocity via the server is what I’d recommend, or in the case that the thing you are trying to apply the velocity to is a player, send a remote event to them telling them to apply the velocity themselves

2 Likes

i have one question though, how would you send a remote event or possibly a bindable event from my character to the enemy’s character to apply velocity on itself?

1 Like

You’d have to send a remote event to the server, and then one to the client you’re targeting.
Also on the server make sure whatever the client is sending checks out, cause if you just do this with no safety checks the client can control any players physics which isnt good

1 Like

Can you give me an example? I’m not sure how you could send a remote event from the server to the client you’re targeting.

1 Like

Well it really depends, what exactly are you trying to do?

1 Like

I’m trying to make a knockback system for my combat game in a local script, Where the character that got punched is detected and should get linear velocity applied on him.

1 Like

hmm I think you should probably change it up a bit.

The client should only be used to tell when they punch, after that you should make the server handle just about everything else (other than animations and effects).

Such as the server should tell if they are on cooldown, and find the actual target that the punch hits. This is cause otherwise any exploiter can just go ahead and hit anyone from anywhere with ease.

1 Like

The problem is that the server is slow. I would like to keep things as they are and create sanity checks in the server in the future. Now, the issue is that I’m not sure how to apply linear velocity to another character that was detected in the client. Based on your earlier posts, it seems like I need to use linear velocity on the server for it to work.

1 Like

Well you could just send a remote event to the server telling it to do the attack or whatever it was, you then do the sanity checks, and if all is good then you detect who your target is, then you could send an event to that client and make it apply linear velocity to itself.

How you find the target is basically the same as how you’d be doing it now, probably with just a couple more steps, just find the target on the server, or do the server client method for hit detection stuff

2 Likes