Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Services
- local ReplicatedStorage = game:GetService('ReplicatedStorage');
- local Resources = require(ReplicatedStorage:WaitForChild('Resources'));
- local Players = game:GetService('Players')
- local TweenService = game:GetService('TweenService')
- local LocalPlayer = Players.LocalPlayer
- local Animating = {}
- Animating.Relay = {}
- --// Mechanics
- function Animating:Animate(Player, Preset, CFrames) -- (Player, {Duration, Style}, {Limb, CFrameStart, CFrameEnd})
- if (Player and Preset and CFrames) == nil then
- return false
- end
- local WeldExist, Weld = false, nil
- local Head = Player.Character:FindFirstChild("Head")
- local Torso = Player.Character:FindFirstChild("Torso")
- local RightArm = Player.Character:FindFirstChild("Right Arm")
- local LeftArm = Player.Character:FindFirstChild("Left Arm")
- local RightLeg = Player.Character:FindFirstChild("Right Leg")
- local LeftLeg = Player.Character:FindFirstChild("Left Leg")
- local Appendiges = {
- RightArm,
- LeftArm,
- RightLeg,
- LeftLeg,
- Head
- }
- local Loaded = true
- for _, v in Appendiges do
- if (v == nil) then
- Loaded = false
- break
- end
- end
- if not Loaded then
- return false
- end
- local Corresponding = {
- Torso:FindFirstChild("Right Shoulder"),
- Torso:FindFirstChild("Left Shoulder"),
- Torso:FindFirstChild("Right Hip"),
- Torso:FindFirstChild("Left Hip"),
- Torso:FindFirstChild("Neck")
- }
- local End = {}
- End.C0 = CFrames[3]
- local Info = TweenInfo.new(
- Preset[1] or 0.1, Preset[2] or Enum.EasingStyle.Linear, Enum.EasingDirection.Out
- )
- for i, weld in pairs(Torso:GetChildren()) do
- if weld:IsA("Weld") and weld.Part1.Name == CFrames[1] then
- WeldExist = true
- Weld = weld
- end
- end
- if not WeldExist then
- Weld = Instance.new("Weld")
- end
- for i, Joints in pairs(Appendiges) do
- if CFrames[1] == Joints.Name then
- Corresponding[i].Part1 = nil
- Weld.Parent = Torso
- Weld.Part0 = Torso
- Weld.Part1 = Joints
- Weld.C0 = CFrames[2]
- local Animation = TweenService:Create(Weld, Info, End)
- Animation:Play()
- end
- end
- return true
- end
- function Animating:ResetAnimations(Player)
- if (Player) == nil then
- return false
- end
- local Head = Player.Character:FindFirstChild("Head")
- local Torso = Player.Character:FindFirstChild("Torso")
- if (Torso == nil) then
- return false
- end
- local RightArm = Player.Character:FindFirstChild("Right Arm")
- local LeftArm = Player.Character:FindFirstChild("Left Arm")
- local RightLeg = Player.Character:FindFirstChild("Right Leg")
- local LeftLeg = Player.Character:FindFirstChild("Left Leg")
- local LS = Torso:FindFirstChild("Left Shoulder")
- local RS = Torso:FindFirstChild("Right Shoulder")
- local LH = Torso:FindFirstChild("Left Hip")
- local RH = Torso:FindFirstChild("Right Hip")
- local NE = Torso:FindFirstChild("Neck")
- local Joints = {
- Torso:FindFirstChild("Right Shoulder"),
- Torso:FindFirstChild("Left Shoulder"),
- Torso:FindFirstChild("Right Hip"),
- Torso:FindFirstChild("Left Hip"),
- Torso:FindFirstChild("Neck")
- }
- local Corresponding = {
- RightArm,
- LeftArm,
- RightLeg,
- LeftLeg,
- Head
- }
- for i , v in Corresponding do
- if (v == nil) then
- table.remove(Corresponding, i)
- table.remove(Joints, i)
- end
- end
- for Index, Weld in pairs(Torso:GetChildren()) do
- if Weld:IsA("Weld") then
- if Weld.Name == 'Held' then
- continue
- end
- Weld:Destroy()
- end
- end
- for i, joint in pairs(Joints) do
- if joint.Part1 ~= Corresponding[i] then
- joint.Part1 = Corresponding[i]
- end
- end
- return true
- end
- --// Events
- Animating.Relay['Animate'] = function(Player, Info, CFrames)
- if (Player == LocalPlayer) then
- return false
- end
- return Animating:Animate(Player, Info, CFrames)
- end
- Animating.Relay['Reset'] = function(Player)
- if (Player == LocalPlayer) then
- return false
- end
- return Animating:ResetAnimations(Player)
- end
- --// Connect Events
- Resources['Functions'].Connect_Remote(Resources['Remotes']:FindFirstChild('Edit Welds'), function(Topic, ...)
- if (Animating.Relay[Topic] ~= nil) then
- return Animating.Relay[Topic](...)
- end
- return false, warn('[ANIMATE]; Relay doesnt have topic; '.. Topic ..' (Edit Welds)')
- end)
- return Animating
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement