Hey I’m lastborn and I’m an intermediate scripter.
For a while now ive been using .Touched events but recently ive been told they arent accurate and are not good practice. What is a better alternative?
Also this is kind of random but could someone link me to a post explaining arguments & parameter.
Thanks everyone
Well, it’s kind of a cheat way to execute events. For example, if a player enters a certain room, instead of checking the player’s HRP position, they could just put a invisible part to execute the code
So a parameter is the Instance of a function’s event. For example, since you have been using .Touched events, the parameter of that event would be the object in the client that is touching the part or object. Parameters are very helpful when working with different types of specific objects because they narrow down the variable that is acting on the function’s event.
Sorry if I’m sounding a bit confusing but I hope I helped
THOUGH
Raycasts are decent for this
1, Accurate (I think lol)
2, Can’t be exploited
For .touched events exploiters can easily bypass it
Delete the part with that event boom bypassed
From what I know they can can’t delete/hook raycasts
This can also be useful for anti-noclip
I am no expert on raycasts but I believe you can keep one active without needing to spam create new ones
If you have some raycast knowledge, I suggest doing that
Interesting idea using raycast to detect the touching part instead, ill look into it but im not too sure about raycast. Do you think region3 would be viable?
From what ive heard touch events are bad practice, raycast are accurate but can sometimes be faulty and region3 are accurate.
Maybe im misinformed though?
Region3 is kind of doodoo. If used for something large-scale like Melee hitboxes for a game, it can really affect the game’s performance. Also, region3 does not support rotation but there are some modules that allow region3 to do so but it costs performance even more.
You should be using Raycast or Touched.
For raycast hitboxes:
Touched isn’t as bad as it seems. It is true that Touched is easily exploitable but you can add some extra checks on the server side. Say you are making a melee hitbox thing. It will be best performance vise for the client to tell the server where and what the client hit. Here, if the player is an exploiter and says that he totally hit a player from 5000 studs away you can just check the distance of the player from the hit part. If its within 5 studs or so you can execute the rest of the code else it wont. Simple right?
Because the player has network ownership of there character the player can tell the server where there position is so checking the position of a character to work out the distance is not safe and can be exploited so touch events ray casting and Region3 can all be exploited all the same