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

How can I make the onTouched event more efficient?

Asked by 10 years ago

Ok so I'm making a gun, and it fires bullets really fast, like at a velocity of 2000 or higher. And I have an onTouched function that damages a player when the bullet hits them, but I've been running into some trouble. Apparently, the onTouched event doesn't work 100% of the time, so if 10 bullets were to hit the player, only 5 or 6 would affect the player. I have a hunch that it's because the bullet is going too fast for the script to detect it. Any advice?

1 answer

Log in to vote
1
Answered by
3rdblox 30
10 years ago

Guns that use moving bullets will always have that problem. It's recommended to use raycasting instead. There's a wiki article: http://wiki.roblox.com/index.php/Raycasting

Ad

Answer this question