Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local repstorage = game:GetService("ReplicatedStorage")
- local Events = repstorage.Events
- local module = {}
- local punchDebounces = {}
- Events.Punch.OnServerEvent:Connect(function(player)
- if punchDebounces[player] then
- return
- end
- local character = player.Character
- if character == nil then
- return
- end
- local humanoid = character:FindFirstChild("Humanoid")
- if humanoid == nil then
- return
- end
- if humanoid.Health == 0 then
- return
- end
- task.spawn(function()
- punchDebounces[player] = true
- task.wait(0.8)
- if punchDebounces[player] then
- punchDebounces[player] = nil
- end
- end)
- local boxCFrame = character.HumanoidRootPart.CFrame
- local boxSize = Vector3.new(5, 5, 5)
- local params = OverlapParams.new()
- params.CollisionGroup = "Default"
- params.FilterDescendantsInstances = {character}
- params.FilterType = Enum.RaycastFilterType.Exclude
- params.MaxParts = 50
- local objectInHitbox = workspace:GetPartBoundsInBox(boxCFrame, boxSize, params)
- task.wait(0.2)
- for _, v in objectInHitbox do
- local otherHumanoid = v.Parent:FindFirstChild("Humanoid")
- if otherHumanoid == nil then
- continue
- end
- if otherHumanoid.Health == 0 then
- return
- end
- local hitParticle = script.HitParticle:Clone()
- hitParticle.Parent = v.Parent.HumanoidRootPart
- hitParticle:Emit(10)
- otherHumanoid.Health -= 30
- task.delay(3, function()
- if hitParticle == nil then
- return
- end
- if hitParticle.Parent == nil then
- return
- end
- hitParticle:Destroy()
- end)
- break
- end
- end)
- return module
Advertisement
Add Comment
Please, Sign In to add comment