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

1game.Workspace.introsound.Sound:Play()

any helpers?

2 answers

Log in to vote
3
Answered by
hiccup111 231 Moderation Voter
10 years ago
1soundList = {
2game.Workspace.IntroSound1,
3game.Workspace.IntroSound2,
4game.Workspace.IntroSound3
5}
6 
7game.Players.PlayerAdded:connect(function(plr)
8    soundList[ math.random(1,#soundList) ]:Play()
9end)
Ad
Log in to vote
-3
Answered by 10 years ago

Try this.

01for i = 1,3 do
02 
03    if i == 1 then
04        game.Workspace.introsound.Sound:Play()
05 
06if i ==2 then
07    game.Workspace.introsound2.Sound:Play()
08 
09    if i ==3 then
10        game.Workspace.introsound3.Sound:Play()
11 
12    end
13end
14    end
15end
0
Seriously, the script indexing is horrible, and this will play all three, not one. Nickoakz 231 — 10y

Answer this question