#HitBox Issue

1 messages · Page 1 of 1 (latest)

graceful frigate
#

When spamming the tool then I get one shotted else when I do it normally click only once it works perfectly buttery smooth fine

#

Here is the local script

#

only for testing

#

thats why it doesnt have with remote event

#
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local punch = script.Parent
local hitbox = game.ReplicatedStorage:WaitForChild("Hitbox")
local anim = punch.Animation

local debounce = false
local runConnection
local track1, track2

local track = animator:LoadAnimation(anim)

track.Priority = Enum.AnimationPriority.Action

punch.Activated:Connect(function()
    if debounce == true then return end
        debounce = true
        track:Play()
        print("played")
        track1 = track:GetMarkerReachedSignal("Punch1"):Connect(function()
            local clone = hitbox:Clone()
            clone.Parent = workspace
            clone.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
            runConnection = RunService.Heartbeat:Connect(function()
                for i,v in pairs(workspace:GetPartsInPart(hitbox)) do
                    local hum = v.Parent:FindFirstChild("Humanoid")
                    if hum then
                        clone:Destroy()
                        hum:TakeDamage(10)
                        runConnection:Disconnect()
                        break
                    end
                end
                track2 = track:GetMarkerReachedSignal("Punch2"):Connect(function()
                    task.wait(1)
                    runConnection:Disconnect()
                    track1:Disconnect()
                    track2:Disconnect()
                    clone:Destroy()
                end)
            end)
            
        end)
        
        task.wait(1)
        debounce = false
end)```
graceful frigate
#

So the issue is

#

when I punch once

#

then spam hit the other one I die

wispy daggerBOT
#

studio** You are now Level 6! **studio

graceful frigate
#

even tho it says 10 damage

#

and sometimes I die even tho I didnt spam click it

#

is it because of the run service?

#

if yes then how do i fix it?

frigid heath
#

load animation 🫀

#

thats already deprecated

#
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local punch = script.Parent
local hitboxTemplate = game.ReplicatedStorage:WaitForChild("Hitbox")
local anim = punch:WaitForChild("Animation")

local debounce = false

punch.Activated:Connect(function()
    if debounce then return end
    debounce = true

    local track = animator:LoadAnimation(anim)
    track.Priority = Enum.AnimationPriority.Action
    track:Play()

    local hitConnection, punch1Conn, punch2Conn

    punch1Conn = track:GetMarkerReachedSignal("Punch1"):Connect(function()
        local clone = hitboxTemplate:Clone()
        clone.Parent = workspace
        clone.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)

        hitConnection = RunService.Heartbeat:Connect(function()
            for _, part in pairs(workspace:GetPartsInPart(clone)) do
                local hum = part.Parent:FindFirstChildOfClass("Humanoid")
                if hum and hum ~= humanoid then
                    hum:TakeDamage(10)
                    clone:Destroy()
                    hitConnection:Disconnect()
                    break
                end
            end
        end)
    end)

    punch2Conn = track:GetMarkerReachedSignal("Punch2"):Connect(function()
        task.wait(0.5)
        if hitConnection then hitConnection:Disconnect() end
        if punch1Conn then punch1Conn:Disconnect() end
        if punch2Conn then punch2Conn:Disconnect() end
    end)

    task.wait(1)
    debounce = false
end)
#

here

graceful frigate
#

oh

#

thx

#

@frigid heath yo so how did you fix it

#

?

#

like it works now

#

if I spam it doesnt like one shot me in less than a sec

graceful frigate
#

?

#

I thought smth else

frigid heath
graceful frigate
#

but what was deprecated

#

I didnt understand it

frigid heath
#

What does the console says

frigid heath
graceful frigate
#

it said nothing

graceful frigate
#

thats why it overlapped

#

and thats also why I got more dmg

#

am I right?

frigid heath
#

Also I added debounce

#

So prevent spamming

#

Imma sleep now bye

graceful frigate
#

k