#hitbox getPartsinPart instantly kils people:

1 messages · Page 1 of 1 (latest)

lavish cedar
#
    run.Heartbeat:Connect(function()
        local parts = workspace:GetPartsInPart(hitbox)
        for _, part in pairs(parts) do
            local parent = part.Parent
            if parent and parent:FindFirstChild("Humanoid") then
                if parent ~= parentModel then
                    parent.Humanoid:TakeDamage(damage)
                end
            end
        end
    end)
end
raw hinge
#

its hitting multiple times

#

coz character made up of more than one part sometimes those many parts will touch the hitbox at the same time so damage will happen more than once

lavish cedar
#

ye

#

i found out that problem too

#

but idk how to fix it

#

@raw hinge

#

Can i instead use a Touched

#

but use heartbeat

raw hinge
#

sure but you'll get the same problem

lavish cedar
#

wait

#

how do i fix it

#
axeEvent.OnServerEvent:Connect(function(player)
    local char = player.Character
    if not char then return end
    local parentModel = char
    local hitbox = axeHitbox:Clone()
    hitbox.Parent = workspace
    local weld = Instance.new("Weld")
    weld.Parent = char:FindFirstChildOfClass("Tool"):WaitForChild("Blade")
    weld.Part0 = char:FindFirstChildOfClass("Tool"):WaitForChild("Blade")
    weld.Part1 = hitbox
    weld.C0 = CFrame.new(0, 0, 0)
    weld.C1 = CFrame.new(0, 0, 0)
    setupHitboxDamage(hitbox, char, 1)
    game.Debris:AddItem(hitbox, 0.7)
end)

--Function for hitboxes


function setupHitboxDamage(hitbox, parentModel, damage)
    local connection
    connection = run.Heartbeat:Connect(function()
        hitbox.Touched:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid") then
                hit.Parent.Humanoid:TakeDamage(damage)
            end
            connection:Disconnect()
        end)
    end)
end
#

This is my new code

#

I just want 1 hit

#

but it stacks dmg

#

@raw hinge

#

Do you know the solution?

raw hinge
#

you are creating a new connection to .touched every heartbeat cmon bruh

lavish cedar
#

i deleted that

#

bro pls help

#

this is my script now

#

@raw hinge what do you suggest

raw hinge
lavish cedar
#

..

#

i learned some fundamentals please don't brush me off

raw hinge
#

and then maybe look up some tutorials

lavish cedar
#

i just need the code then i learn it

raw hinge
#

lol

lavish cedar
#

ok

#

ima go tuorials

raw hinge
lavish cedar
#

what? this is different

#

i learn by examples bro

raw hinge
#

the docs tutorials have lots of examples bro Thumbs

lavish cedar
#

bro

#

whatever ur thinking

#

I just can't think about the logic rn bro

#

this is what scripting help is for

#

i know the basics

raw hinge
#

then you're going to have a hard time learning from the example's logic fingerguns

lavish cedar
#

i can't explain what im trying to do rn

#

ok

#

give me the example

#

ill explain that to you

raw hinge
lavish cedar
#

and how the logic works in it

#

example?

#

Why are you in scripting help bro

#

they could have just told everyone to go in documentation

#

I have a script, and a purpose

raw hinge
lavish cedar
#

and i want help to find out whats wrong

raw hinge
#

and to help myself along the way by learning new stuff

lavish cedar
#

..

#

how are you going to help urself?

raw hinge
#

sometimes people ask about things im not sure about so helping them with it means i learn it too

lavish cedar
#

you can fix people's code and thats better

#

to learn

#

but you tell me to go to docs

#

and read things i know

#

I just need help on what im doing rn

#

If we learn all the logic

raw hinge
lavish cedar
#

Ok?
I understood that

#

and the logic

#

but I can't find how to implement it

raw hinge
#

that is help

#

for any competent coder simply knowing what and why something isn't working is enough for them to fix it

lavish cedar
#

i guess im not competent

#

bro

#

this is not like cheating on a test

#

you can give me the code

raw hinge
#

if you were wondering a pattern to solve this just put all the humanoids that have already been hit in a table so they don't get hit again kind-of like a debounce for anything that takes damage from it

lavish cedar
#

alr

#

lemme try that

raw hinge
#

and putting them into a table shouldn't be hard

lavish cedar
#

alr understood the logic now

raw hinge
#

yet what you don't understand, and arguably the most important part of scripting, is how to come up with new logic sad

lavish cedar
#

these are basics tho

#

ty

#

it workewd

#

so

tawdry delta