Cakey3101

Battlegroudns

Aug 30th, 2025
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | Source Code | 0 0
  1. local UserInputService = game:GetService("UserInputService")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local Players = game:GetService("Players")
  4. local Debris = game:GetService("Debris")
  5. local Workspace = game:GetService("Workspace")
  6.  
  7. local HitboxModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("HitboxModule"))
  8. local Remotes = ReplicatedStorage:WaitForChild("Remotes")
  9.  
  10. local Player = Players.LocalPlayer
  11. local Character = Player.Character or Player.CharacterAdded:Wait()
  12. local Humanoid: Humanoid = Character:WaitForChild("Humanoid")
  13. local Animator: Animator = Humanoid:WaitForChild("Animator")
  14.  
  15. local AnimPrefix = "rbxassetid://"
  16.  
  17. local Data = {
  18.     Punch = {
  19.         OnDebounce = false;
  20.         DebounceTime = 0.5;
  21.         OnNum = 1;
  22.         MaxNum = 3;
  23.         HitPlayers = {};
  24.  
  25.         Animations = {
  26.             [1] = "114477525064186",
  27.             [2] = "75082777380705",
  28.             [3] = "71003130513655",
  29.         }
  30.     },
  31. }
  32.  
  33. local function PlayAnim(Id: string)
  34.     local AnimId = AnimPrefix..Id
  35.  
  36.     local Animation = Instance.new("Animation")
  37.     Animation.AnimationId = AnimId
  38.  
  39.     local AnimTrack = Animator:LoadAnimation(Animation)
  40.  
  41.     AnimTrack:Play()
  42. end
  43.  
  44. UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessedEvent: boolean)
  45.     if GameProcessedEvent then return end
  46.  
  47.     if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  48.         local SelectedChar, CharDataTable = Remotes.GetCharacterInfo:InvokeServer()
  49.  
  50.         if SelectedChar and CharDataTable and Data.Punch.OnDebounce ~= true then
  51.             Data.Punch.OnDebounce = true
  52.  
  53.             if Data.Punch.OnNum + 1 > Data.Punch.MaxNum then
  54.                 Data.Punch.OnNum = 1
  55.             else
  56.                 Data.Punch.OnNum += 1
  57.             end
  58.  
  59.             PlayAnim(Data.Punch.Animations[Data.Punch.OnNum])
  60.  
  61.             local Hitbox = HitboxModule.CreateHitbox(Player, "Block", Vector3.new(5, 5, 5))
  62.  
  63.             Debris:AddItem(Hitbox, 0.1)
  64.  
  65.             Hitbox.Touched:Connect(function(Hit: BasePart)
  66.                 if Hit.Parent:FindFirstChildOfClass("Humanoid") then
  67.                     local HitPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
  68.  
  69.                     if HitPlayer and HitPlayer ~= Player then
  70.                         local HitChar = Hit.Parent
  71.                         local Now = tick()
  72.  
  73.                         if not Data.Punch.HitPlayers[HitPlayer] or Now - Data.Punch.HitPlayers[HitPlayer] >= Data.Punch.DebounceTime then
  74.                             Data.Punch.HitPlayers[HitPlayer] = Now
  75.  
  76.                             print(Player.Name .. " Hit Someone!")
  77.  
  78.                             if Data.Punch.OnNum == 3 then
  79.                                 -- Knockback
  80.                             end
  81.                         end
  82.                     end
  83.  
  84.                     if Hit.Parent.Parent == Workspace:WaitForChild("Dummys") then
  85.                         local HitChar = Hit.Parent
  86.                         local Now = tick()
  87.  
  88.                         if not Data.Punch.HitPlayers["Dummy"] or Now - Data.Punch.HitPlayers["Dummy"] >= Data.Punch.DebounceTime then
  89.                             Data.Punch.HitPlayers["Dummy"] = Now
  90.  
  91.                             print(Player.Name .. " Hit A Dummy!")
  92.  
  93.                             if Data.Punch.OnNum == 3 then
  94.                                 -- Knockback
  95.                             end
  96.                         end
  97.                     end
  98.                 end
  99.             end)
  100.  
  101.             task.wait(Data.Punch.DebounceTime)
  102.             Data.Punch.OnDebounce = false
  103.         end
  104.     end
  105. end)
Advertisement
Add Comment
Please, Sign In to add comment