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

How do you play an audio?

I've never used audio so of course, i'm new to it. How do I call it so it plays?

my weak attempt:

function Play()
	Play(--audio id--)
end

3 answers

✓ Accepted answer

ROBLOX has an object which allows for easy playing of music called Sound. The ID is the asset ID, and the method to call it is "Play".

function Play(audioId)
	local sound = Instance.new("Sound")

	sound.SoundId = audioId
	sound:Play()
end

It's also worthy to note that you should preload sounds, as it will not play until it is loaded. You can find out how to on the ROBLOX Wiki.

local soundid = yoursoundhere

function Play()
local sound = Instance.new("Sound")
sound.SoundId = soundid
sound:Play()
end

This is probably how I'd do it. I haven't tested this though so I'm not sure if it'll work

1 comment

0

If you aren't sure it'll work, I wouldn't really post it, to be honest.

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