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

How do you play an audio?

Asked by 8 years ago

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

Log in to vote
1
Answered by
DeadToMe 105
8 years ago

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.

Ad
Log in to vote
0
Answered by
DevNetx 250 Moderation Voter
8 years ago
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

0
If you aren't sure it'll work, I wouldn't really post it, to be honest. DeadToMe 105 — 8y
Log in to vote
0
Answered by 8 years ago

I suggest that you first ask the ROBLOX WIKI before asking us how to play a Sound

0
already looked at the wiki DeveloperSolo 370 — 8y

Answer this question