this is the function that lets the model move around:
function movemodel()
if model then
mouse.TargetFilter = model
end
if isequipped == true and mouse.Target.Name == "NutrientPart" then
local mousepos = mouse.Hit.p
if model then
model:SetPrimaryPartCFrame(CFrame.new(mousepos))
end
end
end
this is the function that rotates the model:
function rotatemodel()--rotate model
if model then
print("rotating model")
local cframe = model.PrimaryPart.CFrame
model:SetPrimaryPartCFrame(cframe * CFrame.Angles(0,math.rad(45),0))
end
end
the model can be dragged by the mouse and be rotated. however the problem is whenever the model is dragged its rotation resets to a specific position even when you rotate the model first. I want the model to keep its rotation even when its being dragged but I am having issues with it.
--change this line
model:SetPrimaryPartCFrame(CFrame.new(mousepos))
-- to this
model:SetPrimaryPartCFrame(CFrame.new(mousepos)*CFrame.Angles(0,math.rad(model.PrimaryPart.Orientation.Y),0))--this will keep the rotation on the y axis only
your way never worked because every time you moved the model you created a new cframe with no rotation just a position
I had not thought of that, I am a builder but I use some plugins of my own, however, in some of them I had a problem that the rotation was aligned to the camera position (it was a “Tree Placer”), so I had to face a lot I ended up using :MoveTo(). Thanks a lot too!