I made this model which does rotate in the direction of the mouse, but once the mouse moves towards the center of the model, it tilts upwards or downwards. The script works, but moving upwards or downwards isn't what I intended the script to do
It's a local script
Cannon = game.Workspace.Cannon
player = game.Players.LocalPlayer
mouse = player:GetMouse()
local prev_mouse_hit
mouse.Button1Up:connect(function()
end)
mouse.Button1Down:connect(function()
end)
mouse.Move:connect(function()
if mouse.Hit.p ~= prev_mouse_hit then
Cannon:SetPrimaryPartCFrame(CFrame.new(Cannon.PrimaryPart.Position,Vector3.new(mouse.Hit.p.x,0,mouse.Hit.p.z)))
prev_mouse_hit = mouse.Hit.p
end
end)
