Advertisement
SxScripting

Tool Combat System Script [Server]

Jan 24th, 2021 (edited)
17,578
2
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 2 0
  1. local Tool = script.Parent
  2.  
  3. local Player = Tool.Parent.Parent
  4. local Char = Player.Character or Player.CharacterAdded:Wait()
  5. local Humanoid = Char:WaitForChild("Humanoid")
  6.  
  7. local Debounce = {}
  8. local Combo = {}
  9. local bvtable = {0,0,0,0,50}
  10. local HitTimer = {}
  11. local ResetSpeed = {}
  12.  
  13. Tool.Activated:Connect(function()
  14. if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then return end
  15.  
  16. if Debounce[Player] then return end
  17. Debounce[Player] = true
  18.  
  19. if not Combo[Player] then Combo[Player] = 0 end
  20.  
  21. Combo[Player] += 1
  22.  
  23. local Hit1 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit1)
  24. local Hit2 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit2)
  25. local Hit3 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit3)
  26. local Hit4 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit4)
  27. local Hit5 = Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Hit5)
  28.  
  29. local Eyes = Char.HumanoidRootPart.CFrame.LookVector
  30. local Distance = 4.5
  31. local GeneralWaitTIme = .4
  32. local OverallWait = 2.1
  33.  
  34. local RayCastPara = RaycastParams.new()
  35. RayCastPara.FilterDescendantsInstances = {Char}
  36. RayCastPara.FilterType = Enum.RaycastFilterType.Blacklist
  37.  
  38. local RayHitBox = workspace:Raycast((Char.HumanoidRootPart.CFrame).p, Eyes * Distance, RayCastPara)
  39.  
  40. local function resetSpeed(Hum: Humanoid)
  41. if ResetSpeed[Player] then
  42. return
  43. end
  44. ResetSpeed[Player] = game["Run Service"].Heartbeat:Connect(function()
  45. if tick() - HitTimer[Player] < 1 then return end
  46. Hum.WalkSpeed = 16
  47. Hum.JumpPower = 50
  48. ResetSpeed[Player]:Disconnect()
  49. ResetSpeed[Player] = nil
  50. end)
  51. end
  52.  
  53. local function Speed()
  54. HitTimer[Player] = tick()
  55. RayHitBox.Instance.Parent:FindFirstChild("Humanoid").WalkSpeed = 0
  56. RayHitBox.Instance.Parent:FindFirstChild("Humanoid").JumpPower = 0
  57. resetSpeed(RayHitBox.Instance.Parent.Humanoid)
  58. end
  59.  
  60. local function Hitbox()
  61. if RayHitBox then
  62. if RayHitBox.Instance and RayHitBox.Instance.Parent:FindFirstChild("Humanoid") then
  63. if Combo[Player] then
  64. local BV = Instance.new("BodyVelocity",RayHitBox.Instance.Parent:FindFirstChild("HumanoidRootPart"))
  65. BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  66. BV.Velocity = Char.HumanoidRootPart.CFrame.LookVector * bvtable[Combo[Player]]
  67. RayHitBox.Instance.Parent.Humanoid:TakeDamage(5)
  68. game.Debris:AddItem(BV,.5)
  69. Speed()
  70. end
  71. end
  72. end
  73. end
  74.  
  75. if Combo[Player] == 1 then
  76. Hit1:Play()
  77. Hitbox()
  78. wait(GeneralWaitTIme)
  79. end
  80.  
  81. if Combo[Player] == 2 then
  82. Hit2:Play()
  83. Hitbox()
  84. wait(GeneralWaitTIme)
  85. end
  86.  
  87. if Combo[Player] == 3 then
  88. Hit3:Play()
  89. Hitbox()
  90. wait(GeneralWaitTIme)
  91. end
  92.  
  93. if Combo[Player] == 4 then
  94. Hit4:Play()
  95. Hitbox()
  96. wait(GeneralWaitTIme)
  97. end
  98.  
  99. if Combo[Player] == 5 then
  100. Hit5:Play()
  101. Hitbox()
  102. wait(OverallWait)
  103. Combo[Player] = 0
  104. end
  105.  
  106. Debounce[Player] = nil
  107. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement