Advertisement
Guest User

Combat

a guest
Apr 10th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.86 KB | None | 0 0
  1. -- [[ Client Script ]] --
  2. wait(5)
  3. -- [[ Services
  4. local UIS = game:GetService('UserInputService')
  5.  
  6. -- [[ Variables
  7. local plr = game.Players.LocalPlayer
  8. local Char = plr.Character or plr.CharacterAdded:Wait()
  9. local Hum = Char.Humanoid
  10. local Mouse = plr:GetMouse()
  11. local AF = script.CombatAnims
  12. local HAF = script.HeavyCombatAnims
  13.  
  14. -- [[ Settings
  15. local OnCooldown = false
  16. local Combo = 0
  17. local AirCombo = 0
  18. local HeavyCombo = 0
  19. local CanUseCombat = plr:WaitForChild('SecretStats').CanUseCombat
  20. local rdyForAirCombo = false
  21. local CanDoHeavy = true
  22. local CanDoRegular = true
  23.  
  24. -- [[ Sounds
  25. local Hit = script.SwingFist
  26.  
  27. -- [[ Tables
  28. local Anims = {
  29.     [1] = Hum:LoadAnimation(AF.RightPunch), -- Right Punch
  30.     [2] = Hum:LoadAnimation(AF.LeftPunch), -- Left Punch
  31.     [3] = Hum:LoadAnimation(AF.PunchUp), -- Stomac Punch
  32.     [4] = Hum:LoadAnimation(AF.KnockBack), -- Knockback Kick
  33. }
  34.  
  35. local HeavyCombatAnims = {
  36.     [1] = Hum:LoadAnimation(HAF.Hit1), -- first attack
  37.     [2] = Hum:LoadAnimation(HAF.Hit2), -- second attack
  38.     [3] = Hum:LoadAnimation(HAF.Hit3), -- tird attack
  39.     [4] = Hum:LoadAnimation(HAF.Hit4), -- forth attack
  40. }
  41.  
  42. -- [[ Remotes
  43. local StopRunningRemote = game.ReplicatedStorage.PlayerMainSystems.CombatSystem.Remotes.StopRunning
  44. local CombatRemote = game.ReplicatedStorage.PlayerMainSystems.CombatSystem.Remotes.Punched
  45. local HeavyCombatRemote = game.ReplicatedStorage.PlayerMainSystems.CombatSystem.Remotes.HeavyPunched
  46.  
  47. -- Regular Combat
  48. Mouse.button1Down:Connect(function() -- when mouse is clicked
  49.     if OnCooldown == false and CanUseCombat.Value == true and AirCombo == 0 and CanDoRegular == true then
  50.         OnCooldown = true
  51.         CanDoHeavy = false
  52.         HeavyCombo = 0
  53.         Combo = Combo + 1
  54.         Anims[Combo]:Play()
  55.         local Sound = Hit:Clone()
  56.         Sound.Parent = Char.HumanoidRootPart
  57.         Sound:Play()
  58.         game.Debris:AddItem(Sound, .5)
  59.         StopRunningRemote:FireServer()
  60.         CombatRemote:FireServer(Char, Combo)
  61.         wait(.4)
  62.         Anims[Combo]:Stop()
  63.         local newCombo = Combo
  64.         local Xd = coroutine.create(function()
  65.             if wait(.35) and Combo == newCombo then
  66.                 Combo = 0
  67.             elseif Combo == 3 then
  68.                 rdyForAirCombo = true
  69.                 if wait(.35) and AirCombo == 1 then
  70.                     rdyForAirCombo = false
  71.                 end
  72.             end
  73.         end)
  74.         local p = coroutine.create(function()
  75.             if Combo == 1 then
  76.                 HeavyCombo = 1
  77.             elseif Combo == 2 then
  78.                 HeavyCombo = 2
  79.             elseif Combo == 3 then
  80.                 HeavyCombo = 3
  81.             elseif Combo == 4 then
  82.                 HeavyCombo = 0
  83.             end
  84.         end)
  85.         coroutine.resume(Xd)
  86.         coroutine.resume(p)
  87.         if Combo == 4 then
  88.             OnCooldown = true
  89.             Combo = 0
  90.             HeavyCombo = 0
  91.             wait(2)
  92.             OnCooldown = false
  93.             CanDoHeavy = true
  94.         else
  95.             OnCooldown = false
  96.             CanDoRegular = true
  97.             CanDoHeavy = true
  98.         end
  99.     end
  100. end)
  101.  
  102. -- Heavy Combat
  103. Mouse.Button2Down:Connect(function()
  104.     if OnCooldown == false and CanUseCombat.Value == true and AirCombo == 0 and CanDoHeavy == true then
  105.         OnCooldown = true
  106.         CanDoRegular = false
  107.         Combo = 0
  108.         HeavyCombo = HeavyCombo + 1
  109.         HeavyCombatAnims[HeavyCombo]:Play()
  110.         local Sound = Hit:Clone()
  111.         Sound.Parent = Char.HumanoidRootPart
  112.         Sound:Play()
  113.         game.Debris:AddItem(Sound, .5)
  114.         StopRunningRemote:FireServer()
  115.         HeavyCombatRemote:FireServer(Char, HeavyCombo)
  116.         wait(1)
  117.         HeavyCombatAnims[HeavyCombo]:Stop()
  118.         local newCombo = HeavyCombo
  119.         local Xd = coroutine.create(function()
  120.             if wait(.35) and HeavyCombo == newCombo then
  121.                 HeavyCombo = 0
  122.             elseif HeavyCombo == 3 then
  123.                 rdyForAirCombo = true
  124.                 if wait(.35) and AirCombo == 1 then
  125.                     rdyForAirCombo = false
  126.                 end
  127.             end
  128.         end)
  129.         coroutine.resume(Xd)
  130.         OnCooldown = false
  131.         CanDoRegular = true
  132.         if HeavyCombo == 4 then
  133.             OnCooldown = true
  134.             HeavyCombo = 0
  135.             Combo = 0
  136.             wait(2)
  137.             OnCooldown = false
  138.             CanDoHeavy = true
  139.         else
  140.             OnCooldown = false
  141.             CanDoRegular = true
  142.             CanDoHeavy = true
  143.         end
  144.     end
  145. end)
  146.  
  147. -- Air Combat
  148. UIS.InputBegan:Connect(function(input, IsTyping)
  149.     if input.KeyCode == Enum.KeyCode.Space and rdyForAirCombo == true and OnCooldown == false and AirCombo == 0 then
  150.         if IsTyping then return end
  151.         if AirCombo ~= 0 then end
  152.         print('working')
  153.         AirCombo = AirCombo + 1
  154.         wait(.4)
  155.         AirCombo = 0
  156.         HeavyCombo = 0
  157.         Combo = 0
  158.     end
  159. end)
  160.  
  161. -- [[ Server script ]] --
  162. wait(5)
  163. -- [[ Modules
  164. local RagdollModule = require(game.ReplicatedStorage.Modules.RagdollKnock)
  165.  
  166. -- [[ Variables
  167. local RemotesFolder = game.ReplicatedStorage.PlayerMainSystems.CombatSystem.Remotes
  168. local Audio = script.Punched3
  169. local HeavyAudio = script.Slam
  170.  
  171. -- [[ Remotes
  172. local PunchR = RemotesFolder.Punched
  173. local StopRunning = RemotesFolder.StopRunning
  174. local XpForHit = RemotesFolder.CombatExpForHit
  175. local HeavyPunchR = RemotesFolder.HeavyPunched
  176. local HitCombo = RemotesFolder.HitCombo
  177.  
  178. PunchR.OnServerEvent:Connect(function(plr, Char, Combo)
  179.     -- [ Variables
  180.     local Stats = plr:WaitForChild('SecretStats')
  181.     local HEF = script.RegularHitEffect
  182.    
  183.     -- [ Settings
  184.     local CombatDamage = Stats.combatDamage
  185.     local CombatXp = Stats.CombatXp
  186.    
  187.     local hitBox = Instance.new('Part')
  188.     hitBox.Parent = workspace
  189.     hitBox.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -2.75)
  190.     hitBox.Anchored = true
  191.     hitBox.CanCollide = false
  192.     hitBox.Massless = true
  193.     hitBox.Size = Vector3.new(2.5, 2.5, 2.5)
  194.     hitBox.Transparency = .5
  195.     game.Debris:AddItem(hitBox, .25)
  196.    
  197.     -- Movement Section
  198.     local CBV = Instance.new('BodyVelocity', Char.HumanoidRootPart)
  199.     CBV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  200.     CBV.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 4.25
  201.     game.Debris:AddItem(CBV, .15)
  202.    
  203.     -- When HitBox Is Touched by enemie
  204.     hitBox.Touched:Connect(function(hit)
  205.         if hit.Parent:findFirstChild('Humanoid') and hit.Parent ~= Char and hit.Parent:FindFirstChild('WasHit') == nil and hit.Parent:findFirstChild('Invis') == nil then
  206.             -- | Variables | --
  207.             local Enemie = hit.Parent
  208.             local EmieHum = Enemie.Humanoid
  209.            
  210.             -- | Animations | --
  211.             local HitAnims = {
  212.                 [1] = EmieHum:LoadAnimation(HEF.RHE), -- Right Hit
  213.                 [2] = EmieHum:LoadAnimation(HEF.LHE), -- Left Hit
  214.                 [3] = EmieHum:LoadAnimation(HEF.SHE), -- Stomac Hit
  215.                 [4] = EmieHum:LoadAnimation(HEF.KbHE), -- Knockback Hit
  216.             }
  217.            
  218.             local lolz = coroutine.create(function()
  219.                 if game.Players:findFirstChild(Enemie.Name) then
  220.                     local EnemiePlr = game.Player:findFirstChild(Enemie.Name)
  221.                    
  222.                     local CanUseCombat = EnemiePlr.SecretStats.CanUseCombat
  223.                    
  224.                     CanUseCombat = false
  225.                     wait(.45)
  226.                     CanUseCombat = true
  227.                 end
  228.             end)
  229.             coroutine.resume(lolz)
  230.            
  231.             local WasHit = Instance.new('BoolValue', Enemie)
  232.             WasHit.Name = 'WasHit'
  233.             game.Debris:AddItem(WasHit, .4)
  234.            
  235.             local HitAudio = Audio:Clone()
  236.             HitAudio.Parent = hit.Parent.HumanoidRootPart
  237.             HitAudio:Play()
  238.             game.Debris:AddItem(HitAudio, .5)
  239.            
  240.             EmieHum:TakeDamage(CombatDamage.Value)
  241.             HitAnims[Combo]:Play()
  242.             local trash = coroutine.create(function()
  243.                 if Combo < 4 then
  244.                     local EnemieBv = Instance.new('BodyVelocity', Enemie.HumanoidRootPart)
  245.                     EnemieBv.MaxForce = Vector3.new(1e10, 1e10, 1e10)
  246.                     EnemieBv.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 7.5
  247.                     game.Debris:AddItem(EnemieBv, .15)
  248.                 elseif Combo == 4 then
  249.                     local EnemieBv2 = Instance.new('BodyVelocity', Enemie.HumanoidRootPart)
  250.                     EnemieBv2.MaxForce = Vector3.new(1e10, 1e10, 1e10)
  251.                     EnemieBv2.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 35
  252.                     game.Debris:AddItem(EnemieBv2, .15)
  253.                     RagdollModule.Toggle(Enemie, 'On')
  254.                     wait(1.5)
  255.                     RagdollModule.Toggle(Enemie, 'Off')
  256.                 end
  257.             end)
  258.             coroutine.resume(trash)
  259.             wait(.4)
  260.             HitAnims[Combo]:Stop()
  261.         end
  262.     end)
  263. end)
  264.  
  265. HeavyPunchR.OnServerEvent:Connect(function(plr, Char, Combo)
  266.     -- [ Variables
  267.     local Stats = plr:WaitForChild('SecretStats')
  268.     local HEF = script.RegularHitEffect
  269.    
  270.     -- [ Settings
  271.     local CombatDamage = Stats.combatDamage
  272.     local CombatXp = Stats.CombatXp
  273.    
  274.     local hitBox = Instance.new('Part')
  275.     hitBox.Parent = workspace
  276.     hitBox.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -2.75)
  277.     hitBox.Anchored = true
  278.     hitBox.CanCollide = false
  279.     hitBox.Massless = true
  280.     hitBox.Size = Vector3.new(2.5, 2.5, 2.5)
  281.     hitBox.Transparency = .5
  282.     game.Debris:AddItem(hitBox, .25)
  283.    
  284.     -- Movement Section
  285.     local CBV = Instance.new('BodyVelocity', Char.HumanoidRootPart)
  286.     CBV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  287.     CBV.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 4.25
  288.     game.Debris:AddItem(CBV, .15)
  289.    
  290.     local Hit = {}
  291.    
  292.     hitBox.Touched:Connect(function(hit)
  293.         if hit.Parent:findFirstChild('Humanoid') and hit.Parent ~= Char and hit.Parent:FindFirstChild('WasHit') == nil and hit.Parent:findFirstChild('Invis') == nil then      
  294.            
  295.             -- | Variables | --
  296.             local Enemie = hit.Parent
  297.             local EmieHum = Enemie.Humanoid
  298.            
  299.             -- | Animations | --
  300.             local HitAnims = {
  301.                 [1] = EmieHum:LoadAnimation(HEF.RHE), -- Right Hit
  302.                 [2] = EmieHum:LoadAnimation(HEF.LHE), -- Left Hit
  303.                 [3] = EmieHum:LoadAnimation(HEF.SHE), -- Stomac Hit
  304.                 [4] = EmieHum:LoadAnimation(HEF.KbHE), -- Knockback Hit
  305.             }
  306.            
  307.             if game.Players:findFirstChild(Enemie.Name) then
  308.                 local EnemiePlr = game.Player:findFirstChild(Enemie.Name)
  309.                    
  310.                 local CanUseCombat = EnemiePlr.SecretStats.CanUseCombat
  311.                    
  312.                 CanUseCombat = false
  313.                 wait(.45)
  314.                 CanUseCombat = true
  315.             end
  316.            
  317.             local shockwave = game.ReplicatedStorage.PlayerMainSystems.CombatSystem.Effects.BigHitShockwave:Clone()
  318.             shockwave.Parent = workspace
  319.             shockwave.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-2.5)
  320.             game.Debris:AddItem(shockwave, .5)
  321.            
  322.             local HeavyHitAudio = HeavyAudio:Clone()
  323.             HeavyHitAudio.Parent = hit.Parent.HumanoidRootPart
  324.             HeavyHitAudio:Play()
  325.             game.Debris:AddItem(HeavyHitAudio, .5)
  326.            
  327.             local lll = coroutine.create(function()
  328.                 for i = 1, 10 do
  329.                     wait()
  330.                     shockwave.Transparency = shockwave.Transparency  + .1
  331.                     shockwave.CFrame = shockwave.CFrame * CFrame.new(0,0,-.25)
  332.                 end
  333.             end)
  334.             coroutine.resume(lll)
  335.            
  336.             local WasHit = Instance.new('BoolValue', Enemie)
  337.             WasHit.Name = 'WasHit'
  338.             game.Debris:AddItem(WasHit, .4)
  339.            
  340.             EmieHum:TakeDamage(CombatDamage.Value + 1)
  341.             HitAnims[Combo]:Play()
  342.             if Combo < 4 then
  343.                 local EnemieBv = Instance.new('BodyVelocity', Enemie.HumanoidRootPart)
  344.                 EnemieBv.MaxForce = Vector3.new(1e10, 1e10, 1e10)
  345.                 EnemieBv.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 12.5
  346.                 game.Debris:AddItem(EnemieBv, .15)
  347.                 wait(.4)
  348.                 HitAnims[Combo]:Stop()
  349.             elseif Combo == 4 then
  350.                 local EnemieBv2 = Instance.new('BodyVelocity', Enemie.HumanoidRootPart)
  351.                 EnemieBv2.MaxForce = Vector3.new(1e10, 1e10, 1e10)
  352.                 EnemieBv2.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 50
  353.                 game.Debris:AddItem(EnemieBv2, .15)
  354.                 RagdollModule.Toggle(Enemie, 'On')
  355.                 wait(1.5)
  356.                 RagdollModule.Toggle(Enemie, 'Off')
  357.                 wait(.4)
  358.                 HitAnims[Combo]:Stop()
  359.             end        
  360.         end
  361.     end)
  362. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement