lV0rd

Combat local

Mar 14th, 2024
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. local module = {}
  2. module.__index = module
  3.  
  4. local uis = game:GetService("UserInputService")
  5. local repStor = game:GetService("ReplicatedStorage")
  6.  
  7. local setting = require(script.Parent.Important.Settings)
  8. local vM = require(script.Parent.Important.Visuals)
  9. local hbModule = require(script.Parent.Important.HitboxC)
  10. local pull = require(script.Parent.Important.Pull)
  11.  
  12. local remotes = repStor.Remotes
  13. local remote = remotes.Events.M1
  14.  
  15. local visuals = vM.setUp()
  16.  
  17. local plr = game.Players.LocalPlayer
  18. local cam = workspace.CurrentCamera
  19.  
  20. local char : Model
  21. local hum : Humanoid
  22. local anim : Animator
  23. local spra
  24.  
  25. local animF = script.Parent.Important.M1_Animations
  26.  
  27. local animT = {
  28.     animF.Animation,
  29.     animF.Animation2,
  30.     animF.Animation3,
  31. }
  32.  
  33. local lastPunch = tick()
  34. local combo = 0
  35.  
  36. local maxCombo = #animF:GetChildren()
  37.  
  38. local cd = false
  39.  
  40. function module.Init(player)
  41.    
  42.     char = plr.Character or plr.CharacterAdded:Wait()
  43.     hum = char.Humanoid
  44.     anim = hum.Animator
  45.  
  46.     plr.CharacterAdded:Connect(function(c) char = c hum = c.Humanoid anim = c.Humanoid.Animator end)
  47.    
  48.     uis.InputBegan:Connect(function(i, g)
  49.         if g then return end
  50.         if i.UserInputType == setting.M1.InputKey then
  51.             if cd == true then return end
  52.  
  53.             if tick() - lastPunch >= 1 then
  54.                 combo = 0
  55.                 lastPunch = tick()
  56.             end
  57.  
  58.             if combo > maxCombo then
  59.                 combo = 0
  60.             else
  61.                 combo += 1
  62.             end
  63.  
  64.             cd = true
  65.             print(combo)
  66.             anim:LoadAnimation(animT[combo]):Play()
  67.  
  68.             local hitBox = hbModule.CreateHB(setting.M1.HitboxSize, hum.RootPart, 3/2, .6, hum.RootPart)
  69.             local con
  70.             con = hitBox.Touched:Connect(function(hit)
  71.                 if hitBox then
  72.                     if hit.Parent  then
  73.                         if hit.Parent:FindFirstChildOfClass("Humanoid") then
  74.                             if hit.Parent.Name == char.Name then return end
  75.                             local human = hit.Parent:FindFirstChild("Humanoid")
  76.                             if human.Health <= 0 then return end
  77.                             remote:FireServer(human, "b")
  78.                             visuals:DamageParticles(hit.Parent.HumanoidRootPart, 3)
  79.                             pull.Pull(hum.RootPart)
  80.                             print("e")
  81.                             hitBox:Destroy()
  82.                             con:Disconnect()
  83.                             con = nil
  84.                         end
  85.                     end
  86.                 end
  87.             end)
  88.  
  89.             game.Debris:AddItem(hitBox, .4)
  90.             task.wait(.4)
  91.             cd = false
  92.         end
  93.     end)
  94. end
  95.  
  96. return module
  97.  
Advertisement
Add Comment
Please, Sign In to add comment