Is there a more efficient way of detecting collisions?
I'm trying to make a fast paced class fighting game and I've come across a big problem. My script for detecting collision via Touched event isn't working properly. 90% of the time the collision never happens and the damage isn't taken. Here's my script
01 | debounce 1 = weaponpart.Touched:connect( function (hit) |
02 | if (hit.Parent~ = rootPart.Parent and hit.Parent:FindFirstChild( "Humanoid" )~ = nil and hit.Parent:FindFirstChild( "ForceField" ) = = nil ) then |
04 | hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health- 120 |
05 | debounce 1 :disconnect() |
The idea is for the weapon to play an animation, and wait for collision. After 0.3 seconds it disconnects the event to prevent it from firing accidentally
I don't know why this works so poorly but I was wandering if there was a more efficient way of dealing with collisions. One idea was implementing Magnitude detection. But I'm not sure if I want to go down that route