Entity:SetPos sometimes not work for players does not affect them

I just realized that sometimes it not change the position of the player. Which is really annoying. There is no command that force to do that? Not matter if they stuck?

Any chance you’re trying to do it clientside?

There is a issue when you use SetPos before the movement has finished so it will reset the position to the position set in the cmd.

I had to do something funky to get around it, CBaseEntity normally has a function called Teleport that ensures the entity will be moved which does not exist as a lua binding.

To make sure the player will be moved I did something like this:

[lua]-- HACK: SetPos does not ensure that the position wont be modified again by the gamemovement.
– There is currently no ENTITY:Teleport binding.

hook.Add(“FinishMove”, “PlayerTeleport”, function(ply, mv)
local tpData = TELEPORT_QUEUE[ply]
if tpData ~= nil then
return true

local PLAYER_META = FindMetaTable(“Player”)

function PLAYER_META:Teleport(pos, ang, vel)
local data = {}
data.Pos = pos
data.Angles = ang or self:GetAngles()
data.Velocity = vel or self:GetVelocity()
data.Ent = self
TELEPORT_QUEUE[self] = data

Keep in mind that this is only for players.

Ty :slight_smile: