Advertisement
SxScripting

Combat Server Script

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