Alright, so yesterday the gun that I had created was 100% operational and has been that way for almost a year now. Suddenly, one single part of the gun is not working at any of the places that share the script. The issue is when shooting the gun the firing sound does not play anymore. All other sounds work, except for that one sound.
I tried checking to see if the asset was moderated by changing to a different sound, and that did not work. I then though it was an issue because I was calling it inside a local script, so I changed it to a server script, and that did not work. I tried reorganizing the script and even that did not work.
I am at a complete loss with what could have happened in one night that would have broken the gun in all of my places. Has ROBLOX updated anything that could have caused this?
Here is the portion of the code that’s not working:
fireSound:Play() --does not work
Any advice on what I can do to correct this issue would be greatly appreciated!
The problem you are experiencing isn’t clear…
From what I see you are trying to explain is that the fireSound only plays for the user firing the gun, and nobody else can hear it.
If this is your issue, it is the fact that the sound is being played by the client. If you play the sound on the server it will replicate to all clients.
If this is not your issue, please explain the desired outcome and what is going wrong. Simply saying “does not work” tells me nothing about what you are trying to accomplish.
My apologies. I am confused on how to explain what’s going on because I really don’t understand what the issue is.
fireSound is being played on a local script inside each weapon. There are two sounds: one being the fireSound and the other is the reloading sound. Both of these sounds are on the local script. I am 100% aware that these sounds should NOT replicate to other clients, but they did. I know I shouldn’t do that, but if it was working I didn’t want to go through the trouble of fixing it. Whenever I fire the gun, I can NOT hear my gun shots or any other clients (I used to). However, I CAN hear my reloading sound, as well as all other players’.
I tried switching this over to a server script and that did not fix the issue for fireSound not wanting to play.
Here’s my code for local script to call server:
local player = game.Players:FindFirstChild(tostring(plr))
local char = player.Character
if fun == "reloadingevent" then
local reloadSound = char:FindFirstChild("AR2").Barrel.FireSound
if fun == "fireevent" then
local fireSound = char:FindFirstChild("AR2").Barrel.FireSound
fireSound.Pitch= math.random (0.9,0.99)
I really do apologies if this doesn’t make any sense. I simply do not understand what the issue is with why fireSound isn’t working.
What to check for when using a SoundInstance is to make sure it’s in an object like a Part, not a Script or Tool. It seems that it’s in “Barrel” so that’s good. Next, make sure when you fire the Remote in the LocalScript that it exactly says “fireevent”. If the problem is still happening, check in Output by pressing F9 and see if any errors are occurring with the Scripts accossiated with the AR2. Please check for these and report back any information.
I double checked if the event names were the same and they are. There are no errors in console, in fact I put in a print(“works”) and the event does get called, but the sound just doesn’t play.
Sorry for such a late reply But try setting the Sound’s pitch before you Play the sound.
Have you tried checking if the EmitterSize or the MaxDistance property is above zero? The sound’s EmitterSize or MaxDistance might have been changed to zero at some point, which means that nobody can hear it.
If not, I am not sure. You should try replacing the fire sound with a new sound with the same sound id, pitch, volume, and name.
I think the sounds are playing, but the issue is how you’re trying to randomize pitch. math.random only accepts full numbers, no decimals. The result is the pitch being set to 0.
fireSound.Pitch = math.random(90,99) / 100
It’s so weird that it’s been like this for over a year now and suddenly it stops working. Anyway, I believe what you have has fixed the issue. Thanks, man!
Oh boy, i was trying to do a Revolver system and the sound didn’t played. You helped me, i know this thread is from 2 years ago, but you still helping me.