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

Can i make NPC make a short sound everytime they spawn?

i want to make a game where you defend something and npc's are spawning every minute.

2 answers

-- Where the NPC is supposed to respawn, you create a sound like this
-- I usually use functions so I'll drop my own function which I personally recommend.
local Sound = Instance.new("Sound",CharacterPath)
Sound.Volume = .5
Sound.Looped = false
Sound:Play()
-- It's way easier to manage these properties with a function, try out this one for example.
function CreateSound(ID, PARENT, VOLUME, PITCH)
	local Sound = nil
	coroutine.resume(coroutine.create(function()
		Sound = Instance.new("Sound", PARENT)
		Sound.Volume = VOLUME
		Sound.Pitch = PITCH
		Sound.SoundId = "http://www.roblox.com/asset/?id="..ID
		swait()
		Sound:play()
		game:GetService("Debris"):AddItem(Sound, 10)
	end))
	return Sound
end
-- This ensures the sound doesn't play for too long.
-- If you are still struggling feel free to friend me, I'll always accept requests.

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