doesn’t make much of a difference. This is where I downloaded the sound effect: https://www.fesliyanstudios.com/royalty-free-sound-effects-download/gun-shooting-300
scroll down to where it says “rifle automatic A sound effect”
GunFire.Playing = true
Why can’t you just use
GunFire:Play()
Also, you are resetting the TimePosition
if it is greater than 5 or less than 6, which may cut it off short.
if GunFire.TimePosition > 5 and GunFire.TimePosition < 6 then
GunFire.TimePosition = 0
end
What happens if you remove that?
(Also, on a side note, you should use task.wait()
rather than wait()
, it favors performance and is more accurate.)
so then what code would I do for it to stop playing
That wouldn’t change anything, and @Gvvgghnu_Lol you may want to cut off some of the rapid-fire so It’s just two or three beats. In this case, It will loop through those beats one after another because the sound is pretty long and will just continue from where it left off
GunFire:Play()
task.spawn(function()
GunFire.Ended:Wait()
GunFire:Stop()
end)
Granted, this may only work if the sound is not looped, but I don’t see a reason for it to be looped.
I reset it because it kind of echoes at the end. Look at the audio link and you’ll understand.
Are you saying my audio should be like one gun fire instead of automatic?
Audio uploads are free, you could cut it off in a program such as Audacity and then reupload it as the length you would like. Otherwise, this is a very hacky way to do it that I wouldn’t recommend.
Two or three would be recommended but if you have it on loop then it will still be automatic
I just looked at audacity. I searched “gunshot” and nothing came up
and how could I make it actually echo? If I stop the audio, then the audio is stopped, it will not echo.
I don’t know if you understand. Audacity is a program. You could download the gunshot audio file and use Audacity to trim off the parts you don’t want. It isn’t a music/sfx browser, or whatever you think it is. After you trim it, you reupload the audio and change the ID of your sound.
oh ok, sorry
alskdhjgfalksdhgflkasdgflkasdgflkjas
If you parent the echo object to the GunFire it should make it echo
and this overrides the script stopping the sound?
like if I had
local sound = --wherever the sound is
if shooting then
sound:Play()
end
if not shooting then
sound:Stop() -- would the echo still play after this line of code?
end
No, It would not
Summary
This text will be hidden
so there’s no point in adding an echo in my case, since the stop()
would just silence it. How can I have it so it doesn’t get silenced?
The problem is most likely with the accuracy of wait()…
Instead of using a while loop,
local c
c = GunFire:GetPropertyChangedSignal("TimePosition"):Connect(function()
if GunFire.TimePosition > 5 and GunFire.TimePosition < 6 then
GunFire.TimePosition = 0
c:Disconnect()
end
end)
Which would go in place of
while GunFire.Playing == true do
print(GunFire.TimePosition)
if GunFire.TimePosition > 5 and GunFire.TimePosition < 6 then
GunFire.TimePosition = 0
end
wait()
end
Should be quicker.
And no, unless you want to actually change the sound, an echo wouldn’t help.
NOT TESTED. If you have a problem with the code I provided, please tell me.
use task.wait() instead of wait()
I was showing where he should replace it in his code, that is not my code.
I already know to use task.wait()