Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a more efficient way than touched?

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?

1 comment

0

Use a ray.

2 answers

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.