Would this be a good idea for touch detections in general?

So, let’s say you have multiple baseparts you want to have events for getting touched. (e.g. killbricks)

Now you need to use a for loop/collectionservice to do that.

The problem is although being an efficient strategy, it uses up more memory right?

So would it be more effective to do this?

Character.HumanoidRootPart.Touched:Connect(function(hit)
print(hit)
end)

This I would assume take up less memory. And it’s quite simple to do, and works exactly the same. So should I do it? Good idea?

2 Likes

that looks very good i think its more efficient and takes less memory but
you are checking for HumRootPart There are more parts to check for like Legs/Arms/Head
if alot of things are touching the player it may fire the event alot
but yeah i think that is good

amnot sure of that you can wait until someone else respond

Usually the HRP is also touched, but yeah I’ll make sure to use a for loop on all the character’s baseparts. It would still be more effective in the long run though probably.

It depends on the game aswell, maybe some games will only have a few baseparts that need to be touched.

But obbies should probably use this sort of code all the time.

1 Like

yeah am making an obby and i think i will use that method but i will wait for someone to respond amnot sure if it has any cons because i havnot seen anyone using it in a game before