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!
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
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?
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
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