Weird lag on ability

Currently I am working on a dash the player can do to get around. For some reason, their is a strange lag whenever another player uses it. This kinda removes the purpose of having the dash also have invincibility as it seems more like a TP than anything.

I have no clue what causes this to happen as on the clients screen the dash works perfectly. Both players in the clip bellow have a ping of 40~50

Bellow is the script controlling the roll + a video showing off what is happening

The script bellow is an extract of a server script that will run the content bellow when an input is pressed. I just removed all the input stuff as I don’t think it affects the problem

local attach = Instance.new("Attachment",character.HumanoidRootPart)
local dash = Instance.new("LinearVelocity",character.HumanoidRootPart)
				
dash.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
dash.MaxForce = 500000
dash.Attachment0  = attach
local grav = dash:Clone()
grav.Parent = character.HumanoidRootPart
grav.RelativeTo = Enum.ActuatorRelativeTo.World
local load = character.Humanoid:LoadAnimation(script.Dodge)
load:Play()
dash.VectorVelocity = Vector3.new(0,0,-1) * 80
grav.VectorVelocity = Vector3.new(0,-1,0) * workspace.Gravity/4.9
debris:AddItem(dash,0.45)
debris:AddItem(grav,0.45)

Gyazo link incase video does not work

1 Like

my best guess is the server is getting confused on your character’s actual velocity due to using two linear velocities. try removing one temporarily to see if this gets rid of the lag?

1 Like

I have another ability similar that only uses 1 linear velocity, the same lag happens there.

Perhaps it is an issue with linear velocity.
Try using another kind of body mover, like a BodyVelocity.

BodyVelocity is deprecated so I kinda wanna stay away from using it

Try using this:
HumanoidRootPart:SetNetworkOwner(nil)

This could be a networking issue

Try it temporarily so we can see if it is just the bodymover you chose that is causing problems

Ofcourse this is assuming the Humanoid should be controlled by the server.
If the Player should be controlling it do this instead

HumanoidRootPart:SetNetworkOwner( game.Players.Player1 )

This function must be called from a ServerScript

The player is given network ownership of their own character by default

I thought it was an NPC which required the LinearVelocity. In this case, are you creating the LinearVelocity instances on the client?

Sorry you’re not the OP. Oops. 30cr

I’m creating the linear velocity on the server, however, if this was what made the lag I am confused why on the own client there is no lag with the movement.

I’m not 100% sure this is the issue.
If you could test it and let me know if it fixes.

Not sure why it doesn’t lag on the client. :man_shrugging:

Another possible reason could be that the NPC’s mass is lighter than the LocalPlayer’s Character. Maybe the Force is too high

Did you try with another kind of BodyMover?

I ended up just putting it in the client and it works fine now? I really have no clue why it has this weird behaviour but it seems to be working now

1 Like

If the NPC is controlled by the Client then the reason for the Network lag is because the Server is trying to move the Character with LinearVelocity but the NetworkOwnership is set to the LocalPlayer

1 Like

Also just an F.Y.I: Roblox sets the NetworkOwnership of NPCs usually to the LocalPlayer. (Whoever seems to be closest)

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