Advertisement
botchibo

Da Punch Tool

Feb 25th, 2023
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | Gaming | 0 0
  1. -- Define the punch tool
  2. local punchTool = Instance.new("Tool")
  3. punchTool.Name = "Punch Tool"
  4. punchTool.RequiresHandle = false
  5. punchTool.Parent = game.Players.LocalPlayer.Backpack
  6.  
  7. -- Define the punch function
  8. local function punch(player)
  9.     -- Create a hitbox at the player's position
  10.     local hitbox = Instance.new("Part")
  11.     hitbox.Size = Vector3.new(3, 3, 3)
  12.     hitbox.Transparency = 1
  13.     hitbox.CanCollide = false
  14.     hitbox.CFrame = player.Character.HumanoidRootPart.CFrame
  15.     hitbox.Parent = game.Workspace
  16.  
  17.     -- Apply a force to all parts within the hitbox
  18.     local parts = game.Workspace:GetPartsInPart(hitbox)
  19.     for _, part in ipairs(parts) do
  20.         local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
  21.         if humanoid then
  22.             local direction = (part.Position - hitbox.Position).Unit
  23.             humanoid:TakeDamage(10)
  24.             humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
  25.             humanoid:AddImpulse(direction * 10000)
  26.         end
  27.     end
  28.  
  29.     -- Clean up the hitbox
  30.     hitbox:Destroy()
  31. end
  32.  
  33. -- Connect the punch function to the punch tool's equipped event
  34. punchTool.Equipped:Connect(function()
  35.     punchTool.Activated:Connect(function()
  36.         punch(game.Players.LocalPlayer)
  37.     end)
  38. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement