Result (Brick doesn’t sound because I didn’t put it a sound):
For this result, we will modify three scripts and add a folder with sounds. These sounds need to have the name of the materials.
1. BlasterController
We will modify the shoot function:
The code we add grabs the material from the raycast result and stores it in a string value.
We will add the material value to ‘drawRayResults’
2. drawRayResults
We will add the material value to ‘drawRayResults’ and ‘impactEffect’
3. impactEffect
First, we add the material value to ‘impactEffect’. After that, we will check if the material value has ‘Enum.Material.’ in it. Then, we remove ‘Enum.Material.’ from the value.
Our code will check if there’s a sound for the material we shot, and if there’s a sound, it will play it.
Lastly make the delay longer to avoid the audio cutting off.
4. It should work
If you have any issues, I’ll put the .rblx file where I made the tutorial, and I will respond to the replies to this post.
FPS_template_Hit_Sounds.rbxl (134.2 KB)