#Why won't hitbox spawn

1 messages · Page 1 of 1 (latest)

limber atlas
#

Local script:

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

local attackEvent = tool:WaitForChild("AttackEvent") -- RemoteEvent to server

local anims = {
    tool:WaitForChild("Slash1"),
    tool:WaitForChild("Slash2"),
    tool:WaitForChild("Slash3"),
    tool:WaitForChild("Slash4")
}

local currentAttack = 1
local isAttacking = false
local lastAttackTime = 0
local comboResetTime = 1.5
local shortCooldown = 0.1

local stopConnection
local track

tool.Activated:Connect(function()
    local now = tick()

    if now - lastAttackTime > comboResetTime then
        print("Combo timed out — resetting to first slash")
        currentAttack = 1
    end


    if isAttacking then return end
    isAttacking = true

    local anim = anims[currentAttack]
    if not anim then
        isAttacking = false
        return
    end


    if track then
        track:Stop()
        if stopConnection then
            stopConnection:Disconnect()
            stopConnection = nil
        end
    end


    track = animator:LoadAnimation(anim)
    track:Play()
    print("Playing slash", currentAttack)


    attackEvent:FireServer(currentAttack)

    stopConnection = track.Stopped:Connect(function()
        print("Animation ended for slash", currentAttack)
        lastAttackTime = tick()

        currentAttack += 1
        if currentAttack > #anims then
            currentAttack = 1
            wait(0.5)
        end

        task.delay(shortCooldown, function()
            isAttacking = false
        end)


        if stopConnection then
            stopConnection:Disconnect()
            stopConnection = nil
        end
    end)
end)```
#

Server:

#
local damages = {20, 15, 25, 40}
local attackEvent = tool:WaitForChild("AttackEvent")

print("Server attack script loaded for tool:", tool.Name)

attackEvent.OnServerEvent:Connect(function(player, attackIndex)
    print("Attack event received from player:", player.Name, "attackIndex:", attackIndex)

    local character = player.Character
    if not character then
        warn("Player has no character")
        return
    end

    local hrp = character:FindFirstChild("HumanoidRootPart")
    if not hrp then 
        warn("Character missing HumanoidRootPart")
        return
    end

    local hitbox = Instance.new("Part")
    hitbox.Size = (attackIndex == 2) and Vector3.new(99,99,99) or Vector3.new(99,99,99)
    hitbox.Position = hrp.Position 
    hitbox.Anchored = false
    hitbox.CanCollide = false
    hitbox.Transparency = 1
    hitbox.Name = "Hitbox"
    hitbox.Parent = workspace

    local weld = Instance.new("WeldConstraint", hitbox)
    weld.Part0 = hitbox
    weld.Part1 = hrp

    local hitDebounce = {}
    local connection
    connection = hitbox.Touched:Connect(function(hit)
        local enemyHumanoid = hit.Parent and hit.Parent:FindFirstChild("Humanoid")
        if enemyHumanoid and hit.Parent ~= character and not hitDebounce[hit.Parent] then
            hitDebounce[hit.Parent] = true
            enemyHumanoid:TakeDamage(damages[attackIndex])
            print("Damaged:", hit.Parent.Name)
        end
    end)

    game.Debris:AddItem(hitbox, 0.3)


    task.delay(0.3, function()
        if connection then
            connection:Disconnect()
            connection = nil
        end
    end)
end)
amber token
#

cus

#

You set transparency to 1

tepid egret
#

lol

limber atlas
tepid egret
#

@limber atlas

#

if u give me 50 robux ill help u

#

@limber atlas

limber atlas
#

Then no

tepid egret
#

Its cus u set thwe thing to vector 999999

#

u needa set ti to sum like 4,4,4

limber atlas
amber token
#

Its not spawning in workspace?

limber atlas
amber token
#

Too bad

gentle ember
#

weld it