I made a script that makes this enemy model lock on to a player (look at the player). I made it a LocalScript because I wanted the lock-on to not lag behind, and it is working. However, for some reason, the model seems to twitch on the server side while looking perfectly fine on the client side. I have set network ownership of all the model’s parts to the player.
LocalScript:
local RUN_SERVICE = game:GetService("RunService")
local MODEL = script.Model.Value
local MODEL_ROOT = MODEL.HumanoidRootPart
local PLAYER = script.Player.Value
local CHARACTER_MODEL = PLAYER.Character or PLAYER.CharacterAdded:Wait()
local function LookAtPlayer(CharacterModel: Model)
local CharRoot: BasePart = CharacterModel.HumanoidRootPart
MODEL_ROOT.CFrame = CFrame.lookAt(MODEL_ROOT.Position, CharRoot.Position)
end
RUN_SERVICE.RenderStepped:Connect(function()
LookAtPlayer(CHARACTER_MODEL)
end)
Below is a video of what I am talking about. On the left is the server side, while the right is the client side.
Does anybody know why this happens or if there is a way to fix it?
I haven’t but Lerping wouldn’t get the result I want because the enemy’s orientation would start lagging behind. I want the enemy to lock immediately onto the player without any smoothing
Is a server script making the enemy move around the target? If it is then it might be because of the latency difference between the server sided moving script and the local script setting the look direction of the enemy.
Is there are any other ways to track a player model without lagging behind using a server script? If there is, I could use that instead of using a LocalScript.
because network updates every 1/30th of a second, no getting around this without custom replication… which is impossible
consider using physics constraints