Advertisement
StefanBashkir

Tween Model Rotation

Dec 15th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. function _G.AngleSelection(selection, rotation, a_rotation)
  2.     local parts = {}
  3.     local origins = {}
  4.     local function FillSelectedParts(parent)
  5.         for i,v in pairs(parent) do
  6.             if #v:GetChildren() > 0 then
  7.                 FillSelectedParts(v:GetChildren())
  8.                 wait()
  9.             end
  10.             if v:IsA("BasePart") then
  11.                 table.insert(parts, v)
  12.             end
  13.         end
  14.     end
  15.     FillSelectedParts(selection)
  16.     -- Gathered all the origins
  17.     local main = parts[1]
  18.     local frame = (rotation ~= nil and CFrame.new(main.Position) * CFrame.Angles(rotation.x, rotation.y, rotation.z) or main.CFrame * CFrame.Angles(a_rotation.x, a_rotation.y, a_rotation.z))
  19.     for i,v in pairs(parts) do
  20.         origins[v] = main.CFrame:toObjectSpace(v.CFrame)
  21.     end
  22.     --- --- --- --- ---
  23.     -- Adjust them via main part
  24.     for i,v in pairs(origins) do
  25.         i.CFrame = frame:toWorldSpace(v)
  26.     end
  27. end
  28. for i = 1, 90 do
  29.     _G.AngleSelection(script.Parent:GetChildren(), nil, Vector3.new(0,0,math.rad(i)) )
  30.     wait()
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement