Linear Velocity set to Line looks like teleporting to others

I’ve made a dodging system in my game using LinearVelocity using the Line mode, and it looks normal to the player, but to other players and the server I just seem to phase from 1 place to another.

Code I’m using (although I don’t think the problem comes from the code):

	local RollForce = Instance.new("LinearVelocity",HumRP)
	RollForce.Attachment0 = Attachment
	RollForce.Name = "RollForce"
	RollForce.MaxForce = math.huge
	RollForce.VelocityConstraintMode = Enum.VelocityConstraintMode.Line
	RollForce.RelativeTo = Enum.ActuatorRelativeTo.World
	RollForce.LineDirection = Humanoid.MoveDirection
	RollForce.LineVelocity = 45
	Debris:AddItem(RollForce,.25)

Does anyone know what’s going on?

2 Likes

Not sure, but maybe its not replicated? Meaning the physics of the linear velocity only happen on the client but aren’t replicated to the server, therefore only the position the player ends up in is replicated.

Are you running the provided code on a local script or server script?

2 Likes

It’s running on a server script.

Maybe because the max force property is set to math.huge so it’s moving too fast

the max amount it can move is essentially infinite “math.huge

1 Like

Doesn’t seem to change anything, player just seems to teleport but just a lower distance

2 Likes

Maybe try using another method? ApplyImpulse might work? I think I made something similar to a dash in the past, might be able to dig through my stuff and find it, but I can’t think of much off the top of my head right now.

EDIT: Found another post, solution here was to run the linearVelocity on the client… not sure why its like that, but it might work.

3 Likes

It works now, but how would I remove the force if it’s on the client if handling the roll system is on the server? Since I want the roll’s force to be removed if you dodge an attack with perfect timing.

1 Like

You could fire an event back to the client to signal them to remove the linear velocity or you could check for the dodge on both the client and server at the same time, on the client you would then handle the damaging depending on dodging, the client would only check if they dodged to remove the linear velocity again, not to detect any damage or anything.

The latter is probably a bit tedious and I’m sure there is a better way, but using a remote event to send the signal back to the client might cause a delay and lag would certainly affect the system in that case.

I would probably make a shared module script in replicated storage that has a function or something to handle the dodge check, then run it on client and server at the same time, that way you don’t don’t have to write the code for checking twice.

2 Likes

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