#how do i hit multiple humanoids in 1 hitbox?

27 messages · Page 1 of 1 (latest)

clever needle
#

Script?

molten remnant
#

i cant send my script

#

is says ''could deliver mesage""

clever needle
#

Send a smaller portion of the script that just handles the detecting of humanoids?

small badger
molten remnant
#

hitbox4.Touched:Connect(function(hit)
if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
if hitboxcooldown == true then return end

        hitboxcooldown = true
        
        hit.Parent:FindFirstChild("Humanoid"):TakeDamage(35)
clever needle
#

it looks like the hitboxcooldown is going to be set when one thing touches it, so any other things touching it won't get detected.

Instead, make that cooldown humanoid specific by using a table, like cooldowns[humanoid] = true and check for cooldowns[humanoid]. Used tables like that before?

molten remnant
#

no i havent used tables

#

so i should replace the hitboxcooldown with cooldowns[humanoid] = true?

clever needle
#

Well not that exactly

First you need to make a table that'll hold these.

local cooldowns = {} outside of the touched event.

Then, when you want to set the cooldown, you'd do cooldowns[humanoid] = true or false, where "humanoid" is the humanoid that touched.

When you need to check if the cooldown is true or false, you'd do if cooldowns[humanoid] then

molten remnant
#

okay let me try

#

local cooldowns = {}

hitbox4.Touched:Connect(function(hit)
    if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") then
        cooldowns["Humanoid"] = true
        if cooldowns == true then return end
        task.wait(2.5)
        hit.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
#

so this should work?

#

now they die instantly

clever needle
#

You used the string, or word, "Humanoid". That does not work, as that's the same for every touch event, and you didn't adjust the check for seeing if the cooldown was active

You need to save the humanoid you find from FindFirstChild into a variable first, then use that in cooldowns

molten remnant
#

how can i do that?

clever needle
#

I told you

molten remnant
#

im sorry but i really dont know what to do

clever needle
#

what is confusing you specifically

molten remnant
#

how i can safe a humanoid, is it just ''local hitplayer = hit.parent"?

plucky robinBOT
#

studio** You are now Level 3! **studio

clever needle
#

Right way wrong information

You get the humanoid by doing hit.Parent:FindFirstChild("Humanoid"), so that's what you'd save

and hit.Parent isn't necessarily a player.

molten remnant
#

oh

#

but thats already in the script

clever needle
#

If you don't want to save it in a variable then use it, you can just reuse that FindFirstChild

I'm trying not to just give away a script, but you were meant to do cooldowns[hit.Parent:FindFirstChild("Humanoid")]

molten remnant
#

thank you but im really new in scripting so i dont understand what all those """and {} [] mean

clever needle
#

I think then it's more important you learn some programming fundamentals