Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Firing sound ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago
Edited 8 years ago
1function Fire_Gun()
2    local FireSound = Handle:FindFirstChild("FireSound")
3    local Bullet = Handle:FindFirstChild("Bullet")
4 
5    if FireSound then FireSound:Play() end
6    wait(0.2) -- if i add a wait here it won't work, because the gun can fire only every 0.2 seconds so no
7    if Bullet then Bullet:Play() end

So the prob i got is, the sound when gun's fired it plays FireSound and bullet, but if the gun fires like 1000 bullets per minute it's very hard to hear or u just don't hear it. Also the bullet sound sometimes plays first rather than firesound

Fire sound always needs to be first and bullet sounds play like 0.2 seconds later but it fails, how can i make it hear when the weapon fires very fast ?

Also, is there a way to run the whole script but make 1 line wait ? Hope you understand what i mean :)

Please, don't change the script it's fine just explain what's wrong :D

1 answer

Log in to vote
1
Answered by
deris88 146
8 years ago
Edited 8 years ago

Well sound length is a lot more than .2 seconds. Only solution here is adjust time position in sound or increase the pitch. Or you can do this:

01-- every time you shoot create a new sound:
02if FireSound then
03  local ss = Instance.new('Sound') --shoot sound
04  ss.SoundId = 'SoundID'
05  ss.Volume = 1
06  ss.Pitch = 1
07  ss:Play()
08  ss.Parent = script.Parent
09  wait(length of sound)
10  ss:remove()
11end

You need experiment with that! However gun probably will shoot every ' wait(length of sound)'.

In that case you can create another script. Remove the ss:remove() from script above.

1while wait(5) do
2 local sounds = script.Parent:GetChildren()
3 for i= 1,#sounds do
4if sounds[i].ClassName  == '(check the sound class name, i forgot :D)' then
5sounds[i]:remove()
6end
7end
8end

This will solve the case!

0
What do u mean check the sound class name, i forgot ?... Bulvyte 388 — 8y
0
Nvm, u type 1 equal when u needed 2 == Bulvyte 388 — 8y
0
Wel you see every part,instance has ClassName for example block's class name is 'Part', wedges -'Wedge', for script-'Script' deris88 146 — 8y
0
Yes I forgot == :D deris88 146 — 8y
0
Tell me if that works for you! deris88 146 — 8y
Ad

Answer this question