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

What is wrong with my Music Module? It creates errors.

Asked by 4 years ago

Hello, I am experiencing an error while programming a music script. I don't know how to make it loop but, I'm currentley experiencing an error when I am getting the music ID's from the module I made to store audio information. I will attach the scripts here:

01local MusicModule = require(game.ServerScriptService.RestaurantFramework.Music.PlaylistModule)
02local Music = game.ReplicatedStorage.Music
03local isPlaying = false
04 
05function PlaySongs()
06    for i, SongFile in pairs(MusicModule.Playlist) do  
07        isPlaying = true
08        Music.SoundId = ("rbxassetid://"..SongFile.ID)
09        Music.Volume = SongFile.VolumeLevel
10        Music:Play()
11        wait(SongFile.Length)
12        print(SongFile, "finished!")
13        isPlaying = false
14    end
15end
16 
17PlaySongs()

This script errors with:

1ServerScriptService.RestaurantFramework.Music.MusicScript:8: attempt to index number with 'ID'

My Module contains the following:

01local PlaylistModule = {}
02 
03PlaylistModule.Playlist = {
04    {
05        Title = "Dance Monkey",
06        VolumeLevel =  1,
07        AudioLength = 150.386,
08        ID = 4517047588
09    },
10        Title = "Aku Suka Body Mama Muda Roblox",
11        VolumeLevel =  1,
12        AudioLength = 388.78,
13        ID = 4847222635
14}
15 
16return PlaylistModule

Am I missing something because, they both try to run at the same time but, I want the songs to play one by and then play the next after its finished. Is there a method to achieve this? I'm also struggling to make it loop so, if anyone can help I'd appreciate it.

Answer this question