Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make a delay to my sound in these lines of code?

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 :

local Meta = Instance.new("Sound")
	Meta.Name = "Crack"
	Meta.SoundId = "rbxassetid://196857754"
	Meta.Volume = 0.7
	Meta.Pitch = 1
	Meta.Looped = true
	Meta.Parent = bullet
	Meta:play()
	local Feta = Instance.new("Sound")
	Feta.Name = "Plound"
	Feta.SoundId = "rbxassetid://1055286841"
	Feta.Volume = 2.5
	Feta.Pitch = 1
	Feta.Looped = false
	Feta.Parent = bullet
	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:

local Feta = Instance.new("Sound")
        wait(2)
	Feta.Name = "Plound"
	Feta.SoundId = "rbxassetid://1055286841"
	Feta.Volume = 2.5
	Feta.Pitch = 1
	Feta.Looped = false
	Feta.Parent = bullet
	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?

2 comments

0

When you want to play a sound, you should do :Play() instead of :play() since :play() deprecated

0

ok

2 answers

✓ Accepted answer

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.

local Meta = Instance.new("Sound")
Meta.Name = "Crack"
Meta.SoundId = "rbxassetid://196857754"
Meta.Volume = 0.7
Meta.Pitch = 1
Meta.Looped = true
Meta.Parent = bullet
Meta:play()
delay(2, function() -- Delays the function for 2 seconds
	local Feta = Instance.new("Sound")
	Feta.Name = "Plound"
	Feta.SoundId = "rbxassetid://1055286841"
	Feta.Volume = 2.5
	Feta.Pitch = 1
	Feta.Looped = false
	Feta.Parent = bullet
	Feta:play()
end)
-- Putting more here won't delay 2 seconds.

2 comments

1

Also one more thing, the Pitch property is deprecated and is now instead PlaybackSpeed

0

This works like a charm! thank you, i was close from finding it but i was not sure if it was 100% right but this worked thanks alot!

Flip it around. Create Feta play it first. Wait. Then create the other and play. Like this.

    local Feta = Instance.new("Sound")
    Feta.Name = "Plound"
    Feta.SoundId = "rbxassetid://1055286841"
    Feta.Volume = 2.5
    Feta.Pitch = 1
    Feta.Looped = false
    Feta.Parent = bullet
    Feta:play()
wait(2)
local Meta = Instance.new("Sound")
    Meta.Name = "Crack"
    Meta.SoundId = "rbxassetid://196857754"
    Meta.Volume = 0.7
    Meta.Pitch = 1
    Meta.Looped = true
    Meta.Parent = bullet
    Meta:play()

1 comment

0

i tryed this already, this is what i was saying made my gun delay 2 seconds

This discussion is preserved as it was. New answers, comments, and votes are closed.