#How to get multiple parts in the same hitbox?
1 messages · Page 1 of 1 (latest)
yea
** You are now Level 6! **
ok so how would i write that in? (like instead of touched i would put that?)
so instead it would be Hitbox.GetpartsInPart?
ok i will give it a try in a min
local touchingParts = workspace:GetPartsInPart(part)
thank you
like that
oh ok
it means parameters
how would i exclude the hitbox itself (cause i know it is an issue)
Are you beginner?
Ok
i know what params are lol 😭
hi
hello
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
ok thanks
np im js bored
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)
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
the destroyhitbox was linked to animations
one sec
oh destroy hitbox once animation done?
yea
uhh
im not on mac, sorry 😭
np
ok so how would i use touched to get multiple humanoids
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
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?
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
cause I need to re-implement blocking, but when i tried this:
oh
wait lemme adjust 😭
where is the second one
and one here
oh
zestyremote andlightattackremote connections
disregard the zestyremote
both have a hitbox.touched
i made it as a joke and i plan to remove it 😭
oh ok that's the one i edited earlier
we dont need zestyremote?
yea that isnt needed i just forgot to remove it
o
it should be fine cause they functuon the same way
ok
btw should i put the destroy event inside the touched event in order to clear the table? or should the table clearing line go after it sets debounce to false?
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
basically it wont stop the scriot
idk how they work at all
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
and wont affect ur main box of code
ah ok
ill send an example in a bit to help uget a deeper understanding
nvm i think i might be a dummy
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)
np
ok so i have ran into another issue: the blocking system seems to be broken and i don't really know why
what's broken about it
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
so a player that is blocking - is taking the regular damage even tho theyre blocking?
yea
i would make sure that the block check is working fine
im not really sure how it wouldnt be since the last time i used the check it worked fine
well try printing it
so i have to check by looking in the table?
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?
no thats the wrong script thingy
oh?
i used yours
send the current code
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)
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*
yea u didnt need to take out the return
we were debugging
to make sure that particular code block was running
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
oh
okki
just out of curiousity, why should i not
is it like a scripts issue?
no id like for u to see me debugging live as i do it
it was a something froma tutorial i used to make the menu icons
** You are now Level 7! **
i havent actually used any of them tho
ur set up lowkey reminds me of myself when i was starting out xD
im looking thru ur scripts lol
they are really scuffed 😭
what script r we looking at
left mouse
im doing it
ok
i forgot that i set the blocking value to true to test
how does the rig block
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
the rig doenst take damage becuase ur code errors
and stops there
before it can damage
yea ik but if you hit it from behind it, it does
yea
im mkaing sum changes so i can debug better
it's printing isBlocking true
even though im not holdin gF
where's this value representing IsBlocking again
hold on
oh under player
lemme change the default value
Oh
yea its under the player
i clicked f
i tohught F lets u use the m1?
but it also blocks?
do u have to hold F to block
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
u do knjow u can do this right?
yea but i cant hold f on one lcient
then punch on the other
cause then it lets go of f
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?
ok so:
When the player is blocking, the damage goes through as if they arent
(I fixed the press f thing, its just mapped to block now)
The player who is blocking - even though youre in front of them and theyre blocking, they take damage from you?
undo this
should we team test it?
i want the blocking to true by default
ok
nah nrn
seems to be working for me? do u see any problem here?
from the front, im hitting player2 who has IsBlocking true and they arent taking damaga as expeceted?https://gyazo.com/e6e189bf6cddc806de102c7c735c9669
let me try going behind them to see if they take damage (which they should right, even though theyre IsBlocking = true?)
this works too
https://gyazo.com/c2bb69228565a016b90cca75fdb13c10
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
terrible stun function 😭
i was really confused by the folder methos
oh
so i did that and it does work
lowkey i gotta teach u modules
im just not firing stun rn
yea and everything is the same so??
mmmm
so it also turns out that the character that im hitting isnt able to block??
i think something is up here
alr im gonna try that and see what happens
ty for your help today, i really appreciate it
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
kk