How can i retain the model rotation when moving model using SetPrimaryCFrame?
Because whenever i rotate the model by any degree and move it, the model don't retain the rotation i set. This is a problem i'm currently have with my dragging script...
The rotation script.
mouse.KeyDown:connect(function (key) -- Safe rotation
pcall (function()
function rotateMod(mod,rotation)
if key == "r" and _G.target:FindFirstChild("CanRotate") then
local center = mod:GetModelCFrame()
local parts ={}
local function scan(parent)
for _,obj in pairs(parent:GetChildren()) do
if (obj:IsA("BasePart")) then
table.insert(parts,obj)
end
scan(obj)
end
end
scan(mod)
for _,part in pairs(parts) do
part.CFrame = (center*rotation*(center:inverse()*part.CFrame))
end
end
end
rotateMod(_G.target,CFrame.Angles(0,math.rad(10),0))
end)
end)

2 comments
stop using KeyDown :c
the userinputservice didn't fixed it