Anchor position looks delayed or offset on client after setting it on server

Hey everyone,

I’m working on an NPC that jumps toward a player’s head and anchors itself when it touches the target. (like facehugger) The logic runs on the server, and everything works functionally, but I noticed something weird:

After the NPC is anchored on the server, the client sees it slightly behind where it should be — like 1-2 frames behind its final position.

Here’s a simplified version of the logic:

local attackCool = true
function attack(target)
	if attackCool then
		attackCool = false
		headDedector.CanTouch = true
		local head = target.Parent:FindFirstChild("Head")
		if not head then
			head = target
		end

		local myPos = myRoot.Position
		local targetPos = head.Position
		local direction = (targetPos - myPos).Unit
		local distance = (targetPos - myPos).Magnitude

		local verticalOffset = math.clamp(targetPos.Y - myPos.Y, 0, 50)
		local baseJumpPower = 40
		local gravity = workspace.Gravity

		local adjustedJumpPower = baseJumpPower + (verticalOffset * 1.5) * (196.2 / gravity)

		myHuman.JumpPower = adjustedJumpPower
		myHuman.Jump = true

		myRoot.Velocity = direction * math.clamp(distance * 3, 60, 100)

		spawn(function()
			wait(0.1)
			myHuman.JumpPower = baseJumpPower
			wait(0.9)
			attackCool = true
		end)
	end
end

local headDedector = script.Parent:WaitForChild("HeadDedector")


local function onTouch(otherPart)

	if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild("Humanoid") then
		local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
		if humanoid then
			print("head touch!")
			headDedector.CanTouch = false
			myRoot.Anchored = true
		end
	end
end

It jumps forward using velocity, and when it touches the player’s head, it becomes anchored. But on the client, the NPC appears anchored a bit behind the actual hit point for a brief moment.

I’m guessing this is due to client prediction not matching the server’s state?

Has anyone dealt with this before? Any recommended ways to sync position exactly when anchoring like this? Would setting CFrame manually help?

1 Like

Would assume this is due to network ownership (didn’t look at much but this is most likely the issue)

I tried both myRoot:SetNetworkOwnershipAuto() and myRoot:SetNetworkOwner(nil) separately, but there is still a delay. What else can I try?

1 Like