Better way to make click attacks without using .Touched

Hello, I’ve been told by a lot of people that using the “.Touched” function for an M1 system is bad and just not very reliable, and I was trying to use ZonePlus but that’s more for misc things like zones and spawns. What would be a better alternative for .Touched that would get the same job done?

Goal: I’m basically just trying to click, spawn a cube (it’s spawned) and if anybody touches that cube, it detects them and then I can do whatever I want to them, heal, damage, fling, ect, and of course I’m only trying to do this once or should I want to, make it happen several times (but mostly once).

If anybody has any help or advice they can give me that’d be amazing, been working on my M1 system for the last 3 days and I managed to finish all the VFX just yesterday and all the MAIN scripting started today. Thank you for reading if you did read all of this, happy new years, and stay safe!

Have you looked into using GetPartsInPart?
I’m pretty sure there are a few posts about using this instead of the .Touched event.

1 Like

Touched Event isn’t really that bad, but if you prefer using different method, you can use

local hitparts = workspace:GetPartsInPart(hitboxPart)
local alreadyHit = {}
for i, v in pairs(hitparts) do
    if v.Parent:FindFirstChild('Humanoid') and not table.find(alreadyHit, v.Parent) then
        table.insert(alreadyHit, v.Parent)
        v.Parent:FindFirstChild('Humanoid'):TakeDamage(6969)
    end
end

u can do like this

1 Like

You should use this module right here:

I made it for a friend in a couple of minutes but anyone can utilize it. its simple to use and accurately detects things.

If you don’t know how to use it you can just look into module commented code

I have no tried that but I’m 100% gonna read up on it

What is the “alreadyHit” table for? I can see that first whatever the hitbox touches, it scans through it to find the Humanoid and I guess the table makes sure parts aren’t hit more than once? But would that not deal the damage several times or am I stupid?

oo I’ll look through this, thank you

Thank you guys for all this feedback, means a lot, I wasn’t expecting to get much on New Years especially, so thanks for that and happy new years.

Did the module fit your needs for detecting hits?

I mean, there is 6 parts in a one rig, and if every parts of the rig touches hitbox, then the damage will get multiplied by six. And to prevent it, I added alreadyHit table

Not yet, past few days have been rough, bad sleep, so I passed out on my chair LOL

Would you by any chance know how I could say do 10 damage 5 times, or basically just damage the body several times for “barrage” type attacks, or would that just be create the hitbox 5 times

actually nevermind, I’ll just hop into a game with a barrage, something like AUT and check some sort of stand barrage see how the hitbox happens there

Update: So yes it is just several hitboxes, I guess I make the hitbox itself a function and just call it several times?

If its the typical stand barrage you would put a hitbox on each arm spawned then start detecting

https://i.gyazo.com/f2112d9d7266418bec75587506f5b7a2.mp4

Seems like it just multi spawns hit boxes in front of the player

create hitbox 5 times, i think it wojld be better