Advertisement
DanielSiqueira

InputListener_CombatSystem

Dec 25th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. local RepStorage = game:GetService('ReplicatedStorage')
  2. local CombatModule = RepStorage:WaitForChild('CONSTRUCTOR_CombatSystem')
  3.  
  4. local player = game.Players.LocalPlayer
  5. local character = player.Character or player.CharacterAdded:Wait()
  6. local humanoid = character:WaitForChild('Humanoid')
  7.  
  8. local animators = character:WaitForChild('CombatAnimators')
  9. local animations = {[1]=animators:WaitForChild('RightDiagonal');[2]=animators:WaitForChild('LeftDiagonal');[3]=animators:WaitForChild('RightHorizontal')}
  10. local animationTracks = {}
  11.  
  12. for i = 1, #animations do
  13.  
  14. animationTracks[i] = humanoid:LoadAnimation(animations[i])
  15.  
  16. end
  17.  
  18. local UIS = game:GetService('UserInputService')
  19.  
  20. local playerCombatInfo = require(CombatModule).getPlayerCombatInfo(player)
  21.  
  22. local debounce = 0
  23. local timestamp = tick()
  24. local isHolding = false
  25.  
  26. local comboInc = 0
  27.  
  28. local mouse = player:GetMouse()
  29.  
  30.  
  31. local EquipTrack = humanoid:LoadAnimation(script:WaitForChild('EquipAnim'))
  32.  
  33. UIS.InputBegan:Connect(function(input,isTyping)
  34.  
  35. if not isTyping and tick() - timestamp >= debounce then
  36.  
  37. timestamp = tick()
  38. debounce = 0
  39. if input.KeyCode == Enum.KeyCode.One then
  40.  
  41. isHolding = not isHolding
  42.  
  43. playerCombatInfo = require(CombatModule).getPlayerCombatInfo(player)
  44.  
  45. if playerCombatInfo.Weapon then
  46.  
  47. debounce = 0.5
  48. EquipTrack:Play()
  49.  
  50. if isHolding then
  51. wait(0.25)
  52. end
  53.  
  54. playerCombatInfo.Holding = not playerCombatInfo.Holding
  55.  
  56. CombatModule.CombatSystem_SendInputData:InvokeServer('Sword_Equip')
  57.  
  58. end
  59.  
  60. elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
  61.  
  62. playerCombatInfo = require(CombatModule).getPlayerCombatInfo(player)
  63.  
  64. if playerCombatInfo.Holding == false then return end
  65.  
  66. debounce = 0.5
  67.  
  68. comboInc = comboInc < 3 and comboInc + 1 or 1
  69. local track = animationTracks[comboInc]
  70.  
  71. track:Play()
  72.  
  73. CombatModule.CombatSystem_SendInputData:InvokeServer('HitBox_Connect',{playerCombatInfo.Weapon.Handle.Hitbox})
  74.  
  75. track.Stopped:Connect(function()
  76.  
  77. CombatModule.CombatSystem_SendInputData:InvokeServer('HitBox_Disconnect',{playerCombatInfo.Weapon.Handle.Hitbox})
  78.  
  79. end)
  80. end
  81. end
  82. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement