Advertisement
mach10

Untitled

Apr 8th, 2025 (edited)
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.22 KB | None | 0 0
  1. --// Services
  2. local ReplicatedStorage = game:GetService('ReplicatedStorage');
  3. local Resources = require(ReplicatedStorage:WaitForChild('Resources'));
  4.  
  5. local Players = game:GetService('Players')
  6. local TweenService = game:GetService('TweenService')
  7. local LocalPlayer = Players.LocalPlayer
  8.  
  9. local Animating = {}
  10. Animating.Relay = {}
  11.  
  12. --// Mechanics
  13. function Animating:Animate(Player, Preset, CFrames) -- (Player, {Duration, Style}, {Limb, CFrameStart, CFrameEnd})
  14.     if (Player and Preset and CFrames) == nil then
  15.         return false
  16.     end
  17.  
  18.     local WeldExist, Weld = false, nil
  19.  
  20.     local Head = Player.Character:FindFirstChild("Head")
  21.     local Torso = Player.Character:FindFirstChild("Torso")
  22.  
  23.     local RightArm = Player.Character:FindFirstChild("Right Arm")
  24.     local LeftArm = Player.Character:FindFirstChild("Left Arm")
  25.     local RightLeg = Player.Character:FindFirstChild("Right Leg")
  26.     local LeftLeg = Player.Character:FindFirstChild("Left Leg")
  27.  
  28.     local Appendiges = {
  29.         RightArm,
  30.         LeftArm,
  31.         RightLeg,
  32.         LeftLeg,
  33.         Head
  34.     }
  35.  
  36.     local Loaded = true
  37.     for _, v in Appendiges do
  38.         if (v == nil) then
  39.             Loaded = false
  40.             break
  41.         end
  42.     end
  43.  
  44.     if not Loaded then
  45.         return false
  46.     end
  47.  
  48.     local Corresponding = {
  49.         Torso:FindFirstChild("Right Shoulder"),
  50.         Torso:FindFirstChild("Left Shoulder"),
  51.         Torso:FindFirstChild("Right Hip"),
  52.         Torso:FindFirstChild("Left Hip"),
  53.         Torso:FindFirstChild("Neck")
  54.     }
  55.  
  56.     local End = {}
  57.     End.C0 = CFrames[3]
  58.  
  59.     local Info = TweenInfo.new(
  60.         Preset[1] or 0.1, Preset[2] or Enum.EasingStyle.Linear, Enum.EasingDirection.Out
  61.     )
  62.  
  63.     for i, weld in pairs(Torso:GetChildren()) do
  64.         if weld:IsA("Weld") and weld.Part1.Name == CFrames[1] then
  65.             WeldExist = true
  66.             Weld = weld
  67.         end
  68.     end
  69.  
  70.     if not WeldExist then
  71.         Weld = Instance.new("Weld")
  72.     end
  73.  
  74.     for i, Joints in pairs(Appendiges) do
  75.         if CFrames[1] == Joints.Name then
  76.             Corresponding[i].Part1 = nil
  77.  
  78.             Weld.Parent = Torso
  79.             Weld.Part0 = Torso
  80.             Weld.Part1 = Joints
  81.             Weld.C0 = CFrames[2]
  82.  
  83.             local Animation = TweenService:Create(Weld, Info, End)
  84.             Animation:Play()
  85.         end
  86.     end
  87.     return true
  88. end
  89.  
  90. function Animating:ResetAnimations(Player)
  91.     if (Player) == nil then
  92.         return false
  93.     end
  94.  
  95.     local Head = Player.Character:FindFirstChild("Head")
  96.     local Torso = Player.Character:FindFirstChild("Torso")
  97.  
  98.     if (Torso == nil) then
  99.         return false
  100.     end
  101.  
  102.     local RightArm = Player.Character:FindFirstChild("Right Arm")
  103.     local LeftArm = Player.Character:FindFirstChild("Left Arm")
  104.     local RightLeg = Player.Character:FindFirstChild("Right Leg")
  105.     local LeftLeg = Player.Character:FindFirstChild("Left Leg")
  106.  
  107.     local LS = Torso:FindFirstChild("Left Shoulder")
  108.     local RS = Torso:FindFirstChild("Right Shoulder")
  109.     local LH = Torso:FindFirstChild("Left Hip")
  110.     local RH = Torso:FindFirstChild("Right Hip")
  111.     local NE = Torso:FindFirstChild("Neck")
  112.  
  113.     local Joints = {
  114.         Torso:FindFirstChild("Right Shoulder"),
  115.         Torso:FindFirstChild("Left Shoulder"),
  116.         Torso:FindFirstChild("Right Hip"),
  117.         Torso:FindFirstChild("Left Hip"),
  118.         Torso:FindFirstChild("Neck")
  119.     }
  120.  
  121.     local Corresponding = {
  122.         RightArm,
  123.         LeftArm,
  124.         RightLeg,
  125.         LeftLeg,
  126.         Head
  127.     }
  128.  
  129.     for i , v in Corresponding do
  130.         if (v == nil) then
  131.             table.remove(Corresponding, i)
  132.             table.remove(Joints, i)
  133.         end
  134.     end
  135.  
  136.     for Index, Weld in pairs(Torso:GetChildren()) do
  137.         if Weld:IsA("Weld") then
  138.             if Weld.Name == 'Held' then
  139.                 continue
  140.             end
  141.  
  142.             Weld:Destroy()
  143.         end
  144.     end
  145.  
  146.     for i, joint in pairs(Joints) do
  147.         if joint.Part1 ~= Corresponding[i] then
  148.             joint.Part1 = Corresponding[i]
  149.         end
  150.     end
  151.     return true
  152. end
  153.  
  154. --// Events
  155. Animating.Relay['Animate'] = function(Player, Info, CFrames)
  156.     if (Player == LocalPlayer) then
  157.         return false
  158.     end
  159.     return Animating:Animate(Player, Info, CFrames)
  160. end
  161.  
  162. Animating.Relay['Reset'] = function(Player)
  163.     if (Player == LocalPlayer) then
  164.         return false
  165.     end
  166.     return Animating:ResetAnimations(Player)
  167. end
  168.  
  169. --// Connect Events
  170. Resources['Functions'].Connect_Remote(Resources['Remotes']:FindFirstChild('Edit Welds'), function(Topic, ...)
  171.     if (Animating.Relay[Topic] ~= nil) then
  172.         return Animating.Relay[Topic](...)
  173.     end
  174.     return false, warn('[ANIMATE]; Relay doesnt have topic; '.. Topic ..' (Edit Welds)')
  175. end)
  176.  
  177. return Animating
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement