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

How do I make these sounds random?

Asked by 10 years ago

Okay so I have a intro for my game, and I want it to play one song randomly picked out of say 3

and I need help.

The first script is like this

game.Workspace.introsound.Sound:Play()

any helpers?

2 answers

Log in to vote
3
Answered by
hiccup111 231 Moderation Voter
10 years ago
soundList = {
game.Workspace.IntroSound1,
game.Workspace.IntroSound2,
game.Workspace.IntroSound3
}

game.Players.PlayerAdded:connect(function(plr)
    soundList[ math.random(1,#soundList) ]:Play()
end)
Ad
Log in to vote
-3
Answered by 10 years ago

Try this.

for i = 1,3 do

    if i == 1 then
        game.Workspace.introsound.Sound:Play()

if i ==2 then
    game.Workspace.introsound2.Sound:Play()

    if i ==3 then
        game.Workspace.introsound3.Sound:Play()

    end
end
    end
end
0
Seriously, the script indexing is horrible, and this will play all three, not one. Nickoakz 231 — 10y

Answer this question