Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a more efficient way than touched?

Asked by 6 years ago

So im making a hit box for a mob for example a mob is right next to me it touches me it fires it works but Touched event only fires when I do something or move right?

cause when I stood still the touched event did not fire and i stood still and i didnt take any damage i think this might be a problem because people might take advantage of this to get easier farm is there another event that dosent require you to move and if your inside the touch box you automatically take damage?

0
Use a ray. Ince_FS 13 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

Hello! I'm BlackOrange and I will be helping you out today.

Solution:

There are many other ways instead of .Touched to do this type of stuff. Here is a list below:

  1. Touched, Simple event, what you want to do is create a invisible part that moves around the npc and this will make it so that if the part touches the character it will deal damage
  2. Magnitude, You can simply use a infinite loop and check the magnitude. If the NPC is close enough start dealing damage
  3. Raycasting, You can also use rays to do this

Note these solutions will require loops!

More Information:

Touched: wiki.roblox.com/index.php?title=API:Class/BasePart/Touched

Magnitude: https://developer.roblox.com/articles/Magnitude

Raycasting: https://developer.roblox.com/articles/Raycasting

The main point of this answer is to help you get an idea on how to do this. There are many ways to script one thing and get the same result. Some ways are just more efficient.

Hope this helped!

Best of luck developer!

Ad
Log in to vote
0
Answered by 6 years ago

Yes there is. In my opinion, I believe a more efficient tool than touched is Region3. I say this because with Region3 you can check if a player is inside the desired area. An example: If you're trying to make a safezone.

ROBLOX Wiki: https://developer.roblox.com/api-reference/function/Workspace/FindPartsInRegion3

0
*ahem* raycasting is better DeceptiveCaster 3761 — 6y

Answer this question