Touched:Connect running twice or three times?

  1. What do you want to achieve?
    So I’ve recently made my own fps system with its own damage system and I’ve coded in a damage gui to see how much damage a shot deals.

  2. What is the issue?
    The problem I am experiencing is when I hit a headshot on an entity, the shot seems to hit 2 or 3 times which I do not remeber putting in the script. I have a system where if the shot hits the head it will times the damage by 1.5, but not make the shot hit twice.

  3. What solutions have you tried so far?
    I have a feeling this is to do with my ‘Bullet.Touched:Connect(function())’ as it seems to be hitting the head mulitple times and muliplying the damage.

I’ve tried turning CanTouch off when a shot hits as well as Anchoring the bullet with CanCollide off to see if it fixes this bur nothing seems to be stopping this.

If you wish to look at my code I can send it if needed to figure this one out. But for now I can show this gif as a refernce to whats happening.

Extra Dmg error

1 Like

are you using .Touched to know when a bullet hits something? If you are I recommend taking a look at RaycastResult | Documentation - Roblox Creator Hub

1 Like

If you are making a new part each time and using Touched, you can use :Once instead of :Connect or just add a debounce if it’s the same part each time

2 Likes

I’m aware of Raycast and RaycastResult as a system. I use Raycasting to Tween the bullet.

But are you suggesting that I sue RaycastResult instead of a .Touched fuunction?

Oh I didn’t know you can do that, let me try that :slight_smile:

You can use :Raycast() to know what the bullet hit as well, It returns both a HitPosition and a HitPart.

1 Like

I assume you’re tweening the bullet to the raycast HitPosition, but using .Touched because you casted 1 ray. You can send very short raycasts ever frame and update the bullets position until it hits something.

1 Like

You are correct. This is a really cool idea . I didn’t think about that!

I would have to figure out how to add bullet spread to that though.

Thank you so much!

This worked. I wasn’t aware that you could use :Once to prevent a .Touched function from repeating.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.