I am making some sick bullet whizzes, and i could not figure out how to make a delay to the second sound, because you hear the bullet impact first before you hear the shot. here is the code right here :
01 | local Meta = Instance.new( "Sound" ) |
02 | Meta.Name = "Crack" |
03 | Meta.SoundId = "rbxassetid://196857754" |
04 | Meta.Volume = 0.7 |
05 | Meta.Pitch = 1 |
06 | Meta.Looped = true |
07 | Meta.Parent = bullet |
08 | Meta:play() |
09 | local Feta = Instance.new( "Sound" ) |
10 | Feta.Name = "Plound" |
11 | Feta.SoundId = "rbxassetid://1055286841" |
12 | Feta.Volume = 2.5 |
13 | Feta.Pitch = 1 |
14 | Feta.Looped = false |
15 | Feta.Parent = bullet |
16 | Feta:play() |
Feta is the bullet impact which will play first, however meta plays the same time as Feta which is why it needs a delay, now if i put a wait at:
1 | local Feta = Instance.new( "Sound" ) |
2 | wait( 2 ) |
3 | Feta.Name = "Plound" |
4 | Feta.SoundId = "rbxassetid://1055286841" |
5 | Feta.Volume = 2.5 |
6 | Feta.Pitch = 1 |
7 | Feta.Looped = false |
8 | Feta.Parent = bullet |
9 | Feta:play() |
it works but the whole gun delays which means it loads every two seconds so what must i do to make Meta delay for 2 seconds then play sound?
I think you mean you want the delay for the sound without delaying the script. If that's what you mean, you can use delay
to delay the sound without delaying the script.
01 | local Meta = Instance.new( "Sound" ) |
02 | Meta.Name = "Crack" |
03 | Meta.SoundId = "rbxassetid://196857754" |
04 | Meta.Volume = 0.7 |
05 | Meta.Pitch = 1 |
06 | Meta.Looped = true |
07 | Meta.Parent = bullet |
08 | Meta:play() |
09 | delay( 2 , function () -- Delays the function for 2 seconds |
10 | local Feta = Instance.new( "Sound" ) |
11 | Feta.Name = "Plound" |
12 | Feta.SoundId = "rbxassetid://1055286841" |
13 | Feta.Volume = 2.5 |
14 | Feta.Pitch = 1 |
15 | Feta.Looped = false |
16 | Feta.Parent = bullet |
17 | Feta:play() |
18 | end ) |
19 | -- Putting more here won't delay 2 seconds. |
Flip it around. Create Feta play it first. Wait. Then create the other and play. Like this.
01 | local Feta = Instance.new( "Sound" ) |
02 | Feta.Name = "Plound" |
03 | Feta.SoundId = "rbxassetid://1055286841" |
04 | Feta.Volume = 2.5 |
05 | Feta.Pitch = 1 |
06 | Feta.Looped = false |
07 | Feta.Parent = bullet |
08 | Feta:play() |
09 | wait( 2 ) |
10 | local Meta = Instance.new( "Sound" ) |
11 | Meta.Name = "Crack" |
12 | Meta.SoundId = "rbxassetid://196857754" |
13 | Meta.Volume = 0.7 |
14 | Meta.Pitch = 1 |
15 | Meta.Looped = true |
16 | Meta.Parent = bullet |
17 | Meta:play() |