Need help to rotate model with mouse

my goal is to make a model (3D) rotate with/towards the mouse cursor (2D)

btw it should only rotate on 1 axis (see video below)

heres an example i found on the internet (just imagine the square was a 3D model in roblox)

I’ve been trying to find a solution for this when I saw it, and although I don’t have a solution, I’m thinking that you can utilize mouse.Move, x and y components of the mouse, and math.deg or math.rad.

So far this is what I had as a local script in StarterCharacterScripts, and although this isn’t my closest alternative and it doesn’t work for what your trying to do, I’m just gonna keep it here incase I find anything to change so that I can help you do this.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local camera = workspace.Camera
local movingPart = workspace:WaitForChild("movingPart")

print("yoyo")

camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(movingPart.Position + Vector3.new(0, 20, 0), movingPart.Position)

mouse.Move:Connect(function()
	movingPart.Rotation = Vector3.new(0, math.deg( mouse.X ))
end)

Thank you! I will try this! :smiley:

ahh! almost works, it just rotates on the wrong axis

mouse.Move:Connect(function() movingPart.Rotation = Vector3.new(0, math.deg( mouse.X )) end)

It’s not finalized so I don’t suggest it atm although I’ll keep searching

I’ll do that to! Btw thx for helping

1 Like