Make player face part while retaining movement

I’m trying to make a simple lock-on system for my game, everything was going smoothly until I tried to make the character face the part locked onto.
The whole rotation aspect works fine, however it makes the player unable to move. Not sure if I’m just being dumb here or what, here’s the script;

local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(character)

while wait() do
	print(player.LockOn.Value)
	print(tostring(player.LockOn.Value))
	if tostring(player.LockOn.Value) ~= "nil" then
		print("A")
		character.Humanoid.AutoRotate = false
		local lockedplayer = player.LockOn.Value
		print(lockedplayer.PrimaryPart.Position)
		player.Character:SetPrimaryPartCFrame(CFrame.new(player.Character.Torso.Position, lockedplayer.PrimaryPart.Position))
	end
end

I’ve tried replacing Character.Torso with Character.PrimaryPart, which made no difference.


local bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(1, 1, 1) * math.huge

local players = game:GetService("Players")
local player = players:GetPlayerFromCharacter(character)

while game:GetService("RunService").Stepped:Wait() do
	if tostring(player.LockOn.Value) ~= "nil" then

		character.Humanoid.AutoRotate = false
		local lockedplayer = player.LockOn.Value
		
        local cf = CFrame.new(player.Character.Torso.Position, lockedplayer.PrimaryPart.Position)
        bodyGyro.CFrame = cf
	end
end