From 4bc1925f4d8bde838e30a38cf2d3ae593110e56e Mon Sep 17 00:00:00 2001 From: "Mr.Crowley" Date: Sun, 11 Jan 2026 20:37:42 -0600 Subject: [PATCH] Add UpdateRotation method to ClientEntity Introduces ClientEntity.UpdateRotation to update entity rotation and apply it to the spawned entity if it exists. Also fixes SetKey to update the key before calling the handler. --- lib/entities/client/client_entity.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/entities/client/client_entity.lua b/lib/entities/client/client_entity.lua index f7601ee..3bbeb76 100644 --- a/lib/entities/client/client_entity.lua +++ b/lib/entities/client/client_entity.lua @@ -203,12 +203,13 @@ function ClientEntity.SetKey(id, key, value) local oldData = entityData[key] local handlerKey = "On" .. key:sub(1, 1):upper() .. key:sub(2) local handler = rawget(entityData, handlerKey) + entityData[key] = value if handler then pcall(function() handler(entityData, key, value, oldData) end) end - entityData[key] = value + end --- Gets a registered ClientEntity entry. @@ -290,6 +291,25 @@ function ClientEntity.UpdateCoords(id, coords) end entityData.coords = coords Point.UpdateCoords(id, coords) + if entityData.spawned and DoesEntityExist(entityData.spawned) then + print(coords.x, coords.y, coords.z) + SetEntityCoords(entityData.spawned, coords.x, coords.y, coords.z, false, false, false, true) + end +end + +function ClientEntity.UpdateRotation(id, rotation) + local entityData = ClientEntity.All[id] + if not entityData then + print(string.format("[ClientEntity] UpdateRotation: Entity %s does not exist", id)) + return + end + if type(rotation) == "number" or type(rotation) == "string" then + rotation = vector3(0.0, 0.0, tonumber(rotation)) + end + entityData.rotation = rotation + if entityData.spawned and DoesEntityExist(entityData.spawned) then + SetEntityRotation(entityData.spawned, rotation.x, rotation.y, rotation.z, 2, true) + end end --- Changes the model used by a ClientEntity and respawns it if currently spawned.