SHARE
TWEET

Untitled

a guest Jun 19th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local player = game:GetService("Players").LocalPlayer
  2. repeat wait() until player.Character
  3.  
  4. local Animations = {}
  5. Animations["attack1"] = {}
  6. Animations["attack1"]["limit"] = 10
  7. Animations["attack1"][1] = {}
  8. Animations["attack1"][1]["Head"] = CFrame.new(0.504778624, -2.14492607, -0.21496582, 0.629321814, 0.77714479, 0, 0.43457216, -0.351910919, 0.829039097, 0.644283414, -0.52173239, -0.559190691)
  9. Animations["attack1"][1]["Left Arm"] = CFrame.new(-2.08363247, 1.16793633, -0.74540329, 0.504926026, -0.853187978, 0.130843997, 0.73950243, 0.505770862, 0.444220781, -0.445180863, -0.127539158, 0.886311352)
  10. Animations["attack1"][1]["Left Leg"] = CFrame.new(1.00477743, 1.3550725, -0.214962959, 0.629321814, 0.77714479, 0, 0.43457216, -0.351910919, 0.829039097, 0.644283414, -0.52173239, -0.559190691)
  11. Animations["attack1"][1]["Right Arm"] = CFrame.new(-0.995219707, 1.30263233, -1.06057072, 0.629321814, 0.77714479, 0, -0.776671469, 0.628938556, 0.0348970257, 0.0271200407, -0.021961458, 0.9993909)
  12. Animations["attack1"][1]["Right Leg"] = CFrame.new(0.0047852993, 0.700685978, -0.509056091, 0.629321814, 0.77714479, 0, 0.760161996, -0.615569353, 0.207914039, 0.161579326, -0.130844846, -0.978147209)
  13. Animations["attack1"][1]["Torso"] = CFrame.new(0.5047822, -0.644933224, -0.214963913, 0.629321814, 0.77714479, 0, 0.43457216, -0.351910919, 0.829039097, 0.644283414, -0.52173239, -0.559190691)
  14. Animations["idle"] = {}
  15. Animations["idle"]["limit"] = 10
  16. Animations["idle"][1] = {}
  17. Animations["idle"][1]["Torso"] = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  18. Animations["idle"][1]["Left Arm"] = CFrame.new(1.5, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  19. Animations["idle"][1]["Head"] = CFrame.new(0, -1.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  20. Animations["idle"][1]["Left Leg"] = CFrame.new(0.5, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  21. Animations["idle"][1]["Right Arm"] = CFrame.new(-1.5, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  22. Animations["idle"][1]["Right Leg"] = CFrame.new(-0.5, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  23.  
  24. local elapsedtime = 0
  25. local currentFrame = 1
  26. local currentAnimation = "idle"
  27. local override = false
  28. local character = player.Character
  29. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  30. local Humanoid = character:WaitForChild("Humanoid")
  31.  
  32. local function weldBetween(a, b)
  33.     --Make a new Weld and Parent it to a.
  34.     local weld = Instance.new("ManualWeld", a)
  35.     weld.Part0 = a
  36.     weld.Part1 = b
  37.     --Get the CFrame of b relative to a.
  38.     weld.C0 = a.CFrame:inverse() * b.CFrame
  39.     --Return the reference to the weld so that you can change it later.
  40.     return weld
  41. end
  42.  
  43. local CharacterBodyParts = {
  44.     ["Torso"] = weldBetween(character:WaitForChild("Torso"), humanoidRootPart),
  45.     ["Head"] = weldBetween(character:WaitForChild("Head"), humanoidRootPart),
  46.     ["Left Arm"] = weldBetween(character:WaitForChild("Left Arm"), humanoidRootPart),
  47.     ["Right Arm"] = weldBetween(character:WaitForChild("Right Arm"), humanoidRootPart),
  48.     ["Left Leg"] = weldBetween(character:WaitForChild("Left Leg"), humanoidRootPart),
  49.     ["Right Leg"] = weldBetween(character:WaitForChild("Right Leg"), humanoidRootPart)
  50. }
  51.  
  52.  
  53.  
  54. local function update()
  55.     local limit = Animations[currentAnimation].limit
  56.     if elapsedtime > limit then
  57.         elapsedtime = 0
  58.         currentFrame = currentFrame + 1
  59.     end
  60.     if currentFrame > #Animations[currentAnimation] then
  61.         currentFrame = 1
  62.     end
  63.     if not override then
  64.         for part,goal in pairs(Animations[currentAnimation][currentFrame]) do
  65.             CharacterBodyParts[part].C0 = CharacterBodyParts[part].C0:lerp(goal, elapsedtime/limit)
  66.             --print(elapsedtime/limit)
  67.         end
  68.         elapsedtime = elapsedtime + 1
  69.     end
  70. end
  71.  
  72. local Hitted = {}
  73.  
  74. for k,v in pairs(character:GetChildren()) do
  75.     if v:IsA("Part") then
  76.         v.Touched:connect(function(hit)
  77.             if hit.Parent and hit.Parent:FindFirstChild("Humanoid") and not Hitted[hit.Parent.Name] then
  78.                 Hitted[hit.Parent.Name] = true
  79.                 local bV = Instance.new("BodyVelocity")
  80.                 bV.P = 2000
  81.                 bV.maxForce = Vector3.new(13e13, 0, 13e13)
  82.                 bV.velocity = CFrame.new(humanoidRootPart.Position, hit.Position).lookVector*16
  83.                 bV.Parent = hit.Parent
  84.                 game:service("Debris"):AddItem(bV, 1)
  85.             end
  86.         end)
  87.     end
  88. end
  89.  
  90. local UserInputService = game:GetService("UserInputService")
  91.  
  92. UserInputService.InputBegan:connect(function(input)
  93.     if input.UserInputType  == Enum.UserInputType.Keyboard then
  94.         local key = input.KeyCode.Value
  95.         if key == 102 then
  96.             override = true
  97.             currentAnimation = "attack1"
  98.             local limit = Animations[currentAnimation].limit
  99.             for i = 1,limit do
  100.                 for part,goal in pairs(Animations[currentAnimation][1]) do
  101.                     CharacterBodyParts[part].C0 = CharacterBodyParts[part].C0:lerp(goal, i/limit)
  102.                     --print(elapsedtime/limit)
  103.                 end
  104.                 wait()
  105.             end
  106.             currentAnimation = "idle"
  107.             override = false
  108.         end
  109.     end
  110. end)
  111.  
  112.  
  113. local function control()
  114.     if Humanoid.MoveDirection.magnitude > 0 and currentAnimation ~= "walking" then
  115.         --currentAnimation = "walking"
  116.         --currentFrame = 1
  117.         --elapsedtime = 0
  118.         --print("walking")
  119.     elseif Humanoid.MoveDirection.magnitude == 0 and currentAnimation ~= "idle" then
  120.         --currentAnimation = "idle"
  121.         --currentFrame = 1
  122.         --elapsedtime = 0
  123.         --print("idle")
  124.     end
  125. end
  126.  
  127. game:GetService("RunService").RenderStepped:connect(function()
  128.     update()
  129.     control()
  130. end)
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top