I figure this would be a no-brainer but I can’t seem to find a way to do it.
All the ways I know involve putting velocity on a character clientside, but the issue is that there’s that delay between client and server. As a result, the time the velocity starts on the player does not sync up.
I would like to find a way to make it serverside so that at least both clients get synced up, even if there’s a delay.
What I have now is a localscript that runs whenever a server script calls for the player to be moved via RemoteEvent. I tried making one for the server side but the delay is still there for some reason.
(This is for a 2d game, so I would only like there to be knockback in two directions relative to another player)
velocityEvent.OnClientEvent:Connect(function (kbX, kbY)
print("moving " .. localPlayer.Name)
root.Velocity = Vector3.new(0,0,0)
root.RotVelocity = Vector3.new(0,0,0)
if localPlayer.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
if kbY > 0 or kbY < 0 then
localPlayer.Character.Humanoid.PlatformStand = true
end
end
if (root.CFrame.lookVector.X>0) then
root.Velocity = Vector3.new(kbX, kbY, 0)
else
root.Velocity = Vector3.new(-kbX, kbY, 0)
end
wait(0.1)
localPlayer.Character.Humanoid.PlatformStand = false
script.Disabled = true
script.Disabled = false
end)