There's this script that I want to modify it; when you click the button, it plays music but how can I make it so it plays different songs along with it too like a playlist? Here's the script;
1 | bin = script.Parent |
2 | function Clicked() |
3 | bin.Parent.Sound.SoundId = "rbxassetid://142372565" |
4 | bin.Parent.Sound:Play() |
5 | wait( 125 ) |
6 | end |
7 | bin.MouseButton 1 Down:connect(Clicked) |
Also is it possible that I can remove the
1 | wait( 125 ) |
part and make it so that it automatically changes into another song once it ends without having to specifically count 125 seconds?
If I am thinking correctly this is what you want.
01 | local bin = script.Parent |
02 | --Create a table to store all your songs |
03 | local songs = { |
04 | 'rbxassetid://142372565' , |
05 | 'rbxassetid://54654' , |
06 | 'rbxassetid://233' , |
07 | 'rbxassetid://123' , |
08 | 'rbxassetid://asd' , |
09 | 'rbxassetid://ds' , |
10 | 'rbxassetid://djdjdj' , |
11 | } |
12 |
13 | -- Clicked Event |
14 | bin.MouseButton 1 Down:connect( function () |
15 | bin.Parent.SoundId = tostring (songs [ math.random( 1 , #songs) ] ) --Picks a random song from table |
16 | bin.Parent.Sound:Play() |
17 | wait(bin.Parent.Sound.TimeLength) |
18 | end ) |
However, if you want it to play forever then do this
1 | bin.MouseButton 1 Down:connect( function () |
2 | while true do |
3 | wait() |
4 | bin.Parent.SoundId = tostring (songs [ math.random( 1 , #songs) ] ) --Picks a random song from table |
5 | bin.Parent.Sound:Play() |
6 | wait(bin.Parent.Sound.TimeLength) |
7 | end ) |
8 | end |