How do I reset a model's original rotation after it randomly rotating around? I want the model's rotation to be 0,0,0 when I am done with the animation of the model.
local speed = 40
local orig = script.Parent
local rotation = math.random(-360,360)
local cf = orig:GetModelCFrame()
function ModelCFrame(Model,Frame)
local search,MidFrame,list = nil,Model:GetModelCFrame(),{}
search=function(a)
for n,o in pairs(a:GetChildren())do
if(o:IsA("BasePart"))then
table.insert(list,o)
end
search(o)
end
end
search(Model)
for n,o in pairs(list)do
o.CFrame=Frame*MidFrame:toObjectSpace(o.CFrame)
end
end
while(wait())do
rotation = rotation+(speed/5)
if(rotation>360)then rotation = 0 end
ModelCFrame(orig,cf*CFrame.Angles(math.rad(rotation),math.rad(rotation),math.rad(rotation)))
end

1 comment
Have you tried ModelCFrame(orig, cf)? cf should contain the original rotation.