HumanoidRootPart still rotates on Y axis even though i've multiplied it by 1,0,1

trying to make custom shiftlock work and rotate my characters’ humanoid rootpart on camera.cframelookvector, and i got this:

code:

local function EnableShiftlock(root)
	local targetPosition = root.Position + Vector3.new(camera.CFrame.LookVector.X* MAX_LENGTH, 0, camera.CFrame.LookVector.Z * MAX_LENGTH)
	root.CFrame = CFrame.new(root.Position, targetPosition)
end

local function DisableShiftlock()
	pcall(function()
		active:Disconnect()
		active = nil
	end)
end

table.insert(events, Player:GetAttributeChangedSignal("MouseLocked"):Connect(function()
		isMouseLocked = not isMouseLocked
		
		if isMouseLocked then
			active = RunService.RenderStepped:Connect(function()
				EnableShiftlock(RootPart, human)
			end)
			
		else
			DisableShiftlock(human)
			
		end
	end))
1 Like