#How to get multiple parts in the same hitbox?

1 messages · Page 1 of 1 (latest)

coarse night
#

I was wondering if it is possible to get multiple humanoids in a given part. How could I do this? (as the way it is right now only detects one person at a time, even if there are two people in the box.)

Here's the script that detects players and makes hitboxes:

celest lava
#

@coarse night

#

I think using GetPartsInPart

#

u using touched rn, correct?

coarse night
#

yea

shell magnetBOT
#

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

celest lava
#

yea

#

then its getpartsinpart

coarse night
#

ok so how would i write that in? (like instead of touched i would put that?)

#

so instead it would be Hitbox.GetpartsInPart?

celest lava
#

local hits = workspace:GetPartsInPart(ur part here)

#

i think

coarse night
#

ok i will give it a try in a min

celest lava
#

local touchingParts = workspace:GetPartsInPart(part)

coarse night
#

thank you

celest lava
#

like that

coarse night
#

oh ok

celest lava
#

and it has params too

#

like what to include or exclude

coarse night
#

ooh what params

#

oh ok

celest lava
#

it means parameters

coarse night
#

how would i exclude the hitbox itself (cause i know it is an issue)

celest lava
#

Are you beginner?

coarse night
#

no i know 😭

#

im sorta beginner but not really

celest lava
#

Ok

coarse night
#

i know what params are lol 😭

celest lava
#

oh

#

ok

#

so you got it

#

tell me if something goes wrong @coarse night

coarse night
#

alr ill try it

#

am doing smth rn so i might ping in a bit

coarse night
vagrant finch
#

workspace:getpartsinpart(part)

#

this will return a table containing all the parts inside the part u passed

#

u can iterate through them to see if theyre parts of a model that contains a humanoid

coarse night
#

ok thanks

vagrant finch
#

@coarse night

#

this what u want?

coarse night
#

indeedy i guess

#

you didnt have to do that, thank you

vagrant finch
#

np im js bored

coarse night
#

while i have you here, could you tell me where i would put code to link the detection to a function (Like stunning or taking damage) (Sorry to be a bother)

vagrant finch
#

np

#

one moment leme check ur code again

#

so this is just a hitbox once

#

so u dont need .touched

#

and u dont need the destroyhitbox remote

#

if u use my method

coarse night
vagrant finch
#

one sec

vagrant finch
coarse night
#

yea

vagrant finch
#

ah

#

how do i zoom in 😭

#

cmd + aint working

coarse night
#

uhh

vagrant finch
#

nvm

#

figured out a way

#

ok we can stick to using touched

coarse night
#

im not on mac, sorry 😭

vagrant finch
#

np

coarse night
#

ok so how would i use touched to get multiple humanoids

vagrant finch
#

instead of setting debounce to true completely after only one person takes damage

#

you check the table if the person that .touched has debounce to true

#

by using their humanod as the key

#

here's a visual to help understand better:

local debounce = {
[player1Humanoid] = true,
[player2Humanoid] = true,
[player3Humanoid] = true
}
#

so basically before dealing damage

#

check

if debounce[player1Humanoid] then return end -- exit the function if player1Humanoid is a key that is = to true inside the debounce table```
#

i got rid of ur original nested set up whjere u were doing this

#

by just doing if not humanoid then return end, and if debounce then return end

#

same thing

#

just prevents unnecessary nesting

coarse night
#

so why do you not index the debounce table at the end? is it because at that point you need to remove everyone from the table

#

so from here how do I add extra conditions to the conditional?

vagrant finch
#

i made a mistake

#

debounce = false

#

should be

#

debounce[humanoid] = false

#

that means 0.1s after the person was hit theyre able to take damage again if they touch the hitbox

#

but also once ur done with the hitbox ur gonna wanna do table.clear(debounce) which sets each key to nil, if u dont do that then itll affect performance once those tables stack up

coarse night
#

cause I need to re-implement blocking, but when i tried this:

#

oh

#

wait lemme adjust 😭

vagrant finch
#

im so confused

#

why do u have 2 touched events

#

one here

coarse night
#

where is the second one

vagrant finch
#

and one here

coarse night
#

oh

vagrant finch
#

zestyremote andlightattackremote connections

coarse night
#

disregard the zestyremote

vagrant finch
#

both have a hitbox.touched

coarse night
#

i made it as a joke and i plan to remove it 😭

vagrant finch
#

we dont need zestyremote?

coarse night
#

yea that isnt needed i just forgot to remove it

vagrant finch
#

o

coarse night
#

it should be fine cause they functuon the same way

vagrant finch
#

ok

coarse night
vagrant finch
#

uh

#

i have an idea that'll make it way less complicated than it can be

#

just in a separate thread wait 5 seconds and then clear the table

#

because after 5 seconds the animation is basically guaranteed to have been done

#

use task.spawn(functon()

#

wait no

#

use task.delay

#

it waits 5 seconds before running this function

#

have u used task.spawn or coroutine yet

coarse night
#

wouldnt that make the hitbox stay out longer?

#

no

vagrant finch
coarse night
#

idk how they work at all

vagrant finch
#

it wont wait 5 seconds in the script

#

itll open a new thread

#

imagine ur script is this box with code

#

task.delay/task.spawn/coroutine.wrap creates a new box that runs that code

vagrant finch
coarse night
#

ah ok

vagrant finch
#

ill send an example in a bit to help uget a deeper understanding

coarse night
#

so that leaves the question, how do i add to the conditions

#

ok

#

thank you

coarse night
vagrant finch
#

task.spawn/task.delay is the same thing but task.delay u pass a number to wait before running the function (the function is the second argument you pass)

coarse night
#

ok thats crazy useful

#

thanks

vagrant finch
#

np

coarse night
#

ok so i have ran into another issue: the blocking system seems to be broken and i don't really know why

vagrant finch
#

what's broken about it

coarse night
#

when it blocks, it does damage through block

#

the long if statement up top is supposed to be the check, but it doesnt seem to check for it

vagrant finch
#

so a player that is blocking - is taking the regular damage even tho theyre blocking?

coarse night
#

yea

vagrant finch
#

i would make sure that the block check is working fine

coarse night
#

im not really sure how it wouldnt be since the last time i used the check it worked fine

vagrant finch
#

well try printing it

coarse night
#

so i have to check by looking in the table?

vagrant finch
#

so clearly it's failing the if statemenet check if it's going to the else statement where it damages

#

so figure out why that if statement check is failling

#

maybe the dot?

coarse night
#

no thats the wrong script thingy

vagrant finch
#

oh?

coarse night
#

i used yours

vagrant finch
#

send the current code

coarse night
#
Hitbox.Touched:Connect(function(Hit)
            
            local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
            if debounce[Humanoid] then return end
            if not Humanoid then return end
            if  player.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector:Dot(Hit.CFrame.LookVector) <= -0.5 and Players:GetPlayerFromCharacter(Hit.Parent):WaitForChild("IsBlocking").Value == true then
                print("IsBlocked")
            end
            
            debounce[Humanoid] = true
            
            Hit.Parent.Humanoid:TakeDamage(5)
            --StunEvent:FireClient(Players:GetPlayerFromCharacter(Hit.Parent)) These work btw, just needed to check if it was the stun throwing things off
            --ApplyStun(Hit.Parent, 1)
            
            wait(0.1)
            
            debounce[Humanoid] = false
            
            task.delay(5, function()
                table.clear(debounce)
            end)
vagrant finch
#

looks like ur not exiting the code

#

when theyre blocking

#

by returning

coarse night
#

i was returning before, i just changed it cause you told me to print lol 😭

#

so uhh

#

imagine a return in place of the print there*

vagrant finch
#

yea u didnt need to take out the return

#

we were debugging

#

to make sure that particular code block was running

coarse night
#

oops

#

my bad 😭

#

it doesnt give any errors in console so idk whats going on with it

#

for some reason it works on the dummy

vagrant finch
#

ummmmmmmmm

#

lowkey share the place with me

#

ill show u how to debug this

coarse night
#

😭

#

ok ill make a copy and share it

vagrant finch
#

ight

#

share it to gameplayer2769

#

dont send the place file

coarse night
#

oh

vagrant finch
#

click collaborae

coarse night
#

i just found the place file lol

#

alr hold on im gonna dupe it

vagrant finch
#

okki

coarse night
#

is it like a scripts issue?

vagrant finch
#

no id like for u to see me debugging live as i do it

coarse night
#

oh

#

ok

#

i need to friend you so

vagrant finch
#

o

#

send ign

coarse night
#

ill send you a friend request

#

@robertthesalmon

#

ok you should be good to edit

vagrant finch
#

im curious

#

do u use this stuff?

#

the icon module

#

and the stuff under it

coarse night
shell magnetBOT
#

studio** You are now Level 7! **studio

coarse night
#

i havent actually used any of them tho

vagrant finch
#

ur set up lowkey reminds me of myself when i was starting out xD

#

im looking thru ur scripts lol

coarse night
#

they are really scuffed 😭

vagrant finch
#

what script r we looking at

coarse night
#

hitboxes

#

in server script service

vagrant finch
#

how do i use the attack

#

in play test

coarse night
#

left mouse

vagrant finch
#

im doing it

coarse night
#

oh

#

press f

vagrant finch
#

ok

coarse night
#

i forgot that i set the blocking value to true to test

vagrant finch
#

so it's not working for the rig/npc right?

#

does it work for player?

coarse night
#

it doesnt work for actual players

#

it somehow works on the rig

vagrant finch
#

how does the rig block

coarse night
#

has a value in it called isblocking that is set to true

#

but the hitbox script doesnt check for that value so it makes even less sense

vagrant finch
#

the rig doenst take damage becuase ur code errors

#

and stops there

#

before it can damage

coarse night
#

yea ik but if you hit it from behind it, it does

vagrant finch
#

join team test

#

show me

#

how do i use block?

#

@coarse night

coarse night
#

hold f

#

when you let go it gets disabled

vagrant finch
#

@coarse night

#

this is a copy right?

#

u have ur original right?

coarse night
#

yea

vagrant finch
#

im mkaing sum changes so i can debug better

coarse night
#

yea this should be the copy

#

lemme double check

#

yea thats the copy

#

go for it

vagrant finch
#

it's printing isBlocking true

#

even though im not holdin gF

#

where's this value representing IsBlocking again

coarse night
#

hold on

vagrant finch
#

oh under player

coarse night
#

lemme change the default value

vagrant finch
#

Oh

coarse night
#

yea its under the player

vagrant finch
#

i clicked f

#

i tohught F lets u use the m1?

#

but it also blocks?

#

do u have to hold F to block

coarse night
#

you have to press f so that the block release script runs

#

cause by default its set to true so that i didnt have to use multiple computuers

#

ok it should be fixed

vagrant finch
coarse night
#

yea but i cant hold f on one lcient

#

then punch on the other

#

cause then it lets go of f

vagrant finch
#

wait can u describe the problem again:

when u try to hit a player when ur in front of them, even though theyre blocking (because on start it's set to isblocking true) - it damages or doesnt damage?

coarse night
vagrant finch
#

The player who is blocking - even though youre in front of them and theyre blocking, they take damage from you?

coarse night
#

yes

#

i think*

vagrant finch
coarse night
#

should we team test it?

vagrant finch
#

i want the blocking to true by default

coarse night
#

ok

vagrant finch
coarse night
#

all good im gonna set it to true

#

ok its set

vagrant finch
#

let me try going behind them to see if they take damage (which they should right, even though theyre IsBlocking = true?)

coarse night
#

umm

#

yea that should be right

#

it wasnt working 2 seconds ago

#

lemme try

coarse night
#

😭

#

wait im crying what is going on

#

am i schizophrenic?

vagrant finch
#

lel

#

what is this

#

why is it waiting double

#

if u found the isStunned value

#

and if u didnt find the IStunned value then itll error

coarse night
vagrant finch
#

in the elseif

#

cuz ur trying to set nil.value = true

coarse night
#

i was really confused by the folder methos

vagrant finch
#

oh

coarse night
#

so i did that and it does work

vagrant finch
#

lowkey i gotta teach u modules

coarse night
#

im just not firing stun rn

vagrant finch
#

for states

#

itll make ur life

#

100x easie

#

r

coarse night
#

so im not schizophrenic

#

it actually doesnt work in the original

vagrant finch
#

team test to show me

#

?

#

oh

#

but it does in here?

#

interesting

coarse night
#

yea and everything is the same so??

vagrant finch
#

mmmm

coarse night
#

so it also turns out that the character that im hitting isnt able to block??

#

i think something is up here

vagrant finch
#

debug block script

#

prints

coarse night
#

alr im gonna try that and see what happens

#

ty for your help today, i really appreciate it

vagrant finch
#

if u had a state module all youd have to do is

-- getting
local isBlocking = stateModule.getState(player, "IsBlocking")
local isUsingMove = stateModule.getState(player, "IsUsingMove")

-- setting
stateModule.setState(player, "IsBlocking", true)
stateModule.setState(player, "IsUsingMove", true)

and u can store literally anything in there

coarse night
#

woah that sounds promising

#

well i gotta go to sleep so

vagrant finch
#

kk

coarse night
#

thank you for your help today

#

and yesterday