Advertisement
SpacecowboyHX

Untitled

Mar 19th, 2023
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. local function unim(a)
  2.  
  3. local class = a.ClassName
  4.  
  5. local methods = {
  6.  
  7. Model = {
  8. CFrame = function(frame)
  9.  
  10. local origin = a:GetBoundingBox()
  11.  
  12. local pivot = a.WorldPivot
  13.  
  14. if not frame then
  15. return origin
  16. end
  17.  
  18. a.WorldPivot = frame
  19.  
  20. local all = a:GetDescendants()
  21. for _,v in pairs(all) do
  22.  
  23. if not v:IsA("BasePart") then
  24. continue
  25. end
  26.  
  27. local relative = origin:ToObjectSpace(v.CFrame)
  28.  
  29. local new = frame*relative
  30.  
  31. v.CFrame = new
  32. end
  33. end,
  34. Size = function(size)
  35.  
  36. if not size then
  37. return a:GetScale()
  38. end
  39.  
  40. a:ScaleTo(size)
  41. end,
  42. },
  43. BasePart = {}
  44. }
  45.  
  46. for name,funcs in pairs(methods) do
  47.  
  48. if not funcs.CFrame or not funcs.Size then
  49. continue
  50. end
  51.  
  52. funcs.Position = function(position)
  53.  
  54. if not position then
  55. return funcs.CFrame().Position
  56. end
  57.  
  58. local rot = funcs.CFrame():ToOrientation()
  59.  
  60. funcs.CFrame(CFrame.new(position)*rot)
  61. end
  62. funcs.Orientation = function(rotation)
  63.  
  64. if not rotation then
  65.  
  66. local rot = funcs.CFrame():ToEulerAnglesXYZ()
  67.  
  68. return Vector3.new(rot.X,rot.Y,rot.Z)
  69. end
  70.  
  71. local angles = CFrame.fromOrientation(math.rad(rotation.X),math.rad(rotation.Y),math.rad(rotation.Z))
  72.  
  73. local res = funcs.CFrame(CFrame.new(funcs.Position())*angles)
  74. end
  75. end
  76.  
  77. local function method(v)
  78.  
  79. local find = methods[v.ClassName] and v.ClassName or (v:IsA("BasePart") and "BasePart" or v.ClassName)
  80.  
  81. return methods[find] or error("unsupported class; ",v.ClassName)
  82. end
  83.  
  84. local manipulator = setmetatable({},{
  85. __index = function(t,i)
  86.  
  87. local func = method(a)[i]
  88.  
  89. if func then
  90. return func()
  91. end
  92.  
  93. return a[i]
  94. end,
  95. __newindex = function(t,i,v)
  96.  
  97. local func = method(a)[i]
  98.  
  99. if func then
  100. func(v)
  101. return
  102. end
  103.  
  104. a[i] = v
  105. end,
  106. })
  107.  
  108. return manipulator
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement