How to make a model rotate towards mouse?

  1. What do you want to achieve? Keep it simple and clear!
    I would like to make a union or model rotate towards the players mouse.
  2. What is the issue? Include screenshots / videos if possible!
    Well, it doesn’t really rotate towards the mouse. When I move the mouse, it sort of spins around and kind of rotates towards it. It keeps shaking aswell.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried changing the axis on the mouse. Didn’t change much.

Heres my script:


local RS = game:GetService("RunService")
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()



while wait() do
	local x, y, z = Mouse.hit:ToEulerAnglesXYZ()
	
	local TurretModel = character:WaitForChild("UpperTorso")
	print(Mouse.Hit.y)

	TurretModel.CFrame = CFrame.Angles(0, math.rad(Mouse.Hit.y), 0)
end
	

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Mouse.hit should be changed into Mouse.Hit

If I am correct, you are trying to rotate the player’s torso to face the mouse hit.

This new script rotates the players torso differently, using the UpperTorso’s waist or Motor6D to rotate the players UpperTorso.
Using the HumanoidRootPart to get the torso’s orientation prevents the Torso from glitching out.

local RunService = game:GetService("RunService")

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()

local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart",20)
local Waist = Character:WaitForChild("UpperTorso", 20):WaitForChild("Waist", 20)

local OriginalWaistPosition = Waist.C0

RunService.RenderStepped:Connect(function()
	local _,Y,_ = CFrame.new(HumanoidRootPart.Position,Mouse.Hit.Position):ToOrientation()
	Waist.C0 = OriginalWaistPosition * CFrame.Angles(0,Y - math.rad(HumanoidRootPart.Orientation.Y),0)
end)