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

What's wrong with my playlist script and how do I fix it? It wont work in game.

Asked by 5 years ago
Edited 5 years ago

I have config folders attached too.

`--Made By GoldPixelGamingYTPC--

-- ~songs

sound1 = script.Songs.SongID1.Value

sound2 = script.Songs.SongID2.Value

sound3 = script.Songs.SongID3.Value

sound4 = script.Songs.SongID4.Value

sound5 = script.Songs.SongID5.Value

sound6 = script.Songs.SongID6.Value

sound7 = script.Songs.SongID7.Value

sound8 = script.Songs.SongID8.Value

sound9 = script.Songs.SongID9.Value

sound10 = script.Songs.SongID10.Value

sound11 = script.Songs.SongID11.Value

sound12 = script.Songs.SongID12.Value

sound13 = script.Songs.SongID13.Value

sound14 = script.Songs.SongID14.Value

sound15 = script.Songs.SongID15.Value

sound16 = script.Songs.SongID16.Value

--

local music = Instance.new("Sound") -- Do not change this

music.Archivable = true -- Do not change this

music.parent = script.Parent

local songtime = music.TimeLength

--

music.Name = "Music player"

music.Volume = script.Settings.Volume.Value

music.Pitch = script.Settings.Pitch_or_Speed.Value

music.Looped = script.Settings.Looped.Value

echo = script.Settings.Echo.Value

--

if echo and true

then

EchoEffect = Instance.new("EchoSoundEffect")

EchoEffect.Parent = music

if echo and false

then

end

else

print "Error"

end

print 'Loading Sound'

while (true) do -- process of playing the list

music.SoundId = sound1

music:Play()

wait(songtime+0.25)

music.SoundId = sound2

music:Play()

wait(songtime+0.25)

music.SoundId = sound3

music:Play()

wait(songtime+0.25)

music.SoundId = sound4

music:Play()

wait(songtime+0.25)

music.SoundId = sound5

music:Play()

wait(songtime+0.25)

music.SoundId = sound6

music:Play()

wait(songtime+0.25)

music.SoundId = sound7

music:Play()

wait(songtime+0.25)

music.SoundId = sound8

music:Play()

wait(songtime+0.25)

music.SoundId = sound9

music:Play()

wait(songtime+0.25)

music.SoundId = sound10

music:Play()

wait(songtime+0.25)

music.SoundId = sound11

music:Play()

wait(songtime+0.25)

music.SoundId = sound12

music:Play()

wait(songtime+0.25)

music.SoundId = sound13

music:Play()

wait(songtime+0.25)

music.SoundId = sound14

music:Play()

wait(songtime+0.25)

music.SoundId = sound15

music:Play()

wait(songtime+0.25)

music.SoundId = sound16

music:Play()

wait(songtime+0.25)

end`

what's wrong with it that it doesn't work? also I sorry but the code thing will only work for line 1

0
you don't need to use the values of the object, just use "rbxassetid://ID PUT IT HERE" cherrythetree 130 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Asset IDs (such as Audio, Decal, or Model) use a link, not a number itself. In this case, it would be "rbxassetid://000000000", a string, where 000000000 is the ID you want.

What I suggest is that you do this instead of writing all of those variables:

local children = script.Parent:GetChildren()

This returns a table of every child of the script's Parent. The children should be the Script, the IDs, and any other Instances (if there are any other Instances).

For assigning the ID, concatenate the ID number into the link:

 for _, i in pairs(children) do
        if i.ClassName == "IntValue" then
            music.SoundId = "rbxassetid://" .. i.Value
            music:Play()
            music.Ended:Wait() -- This waits until the music ends to play the next ID
        end
end

The above script should fix your problem.

0
@MCAndRobloxUnited Thanks, I will try this, but is here a way I can add the values in the config files so that a user can easily modify the sound? Also is there a way i can allow unlimited sounds without adding so many sound variables, or does the `local children = script.parent:GetChildren()` do that?    GoldPixelGamingYTPC 0 — 5y
0
GetChildren() gets all of the script's children, so no matter how many children there are they will all be in the returned table. DeceptiveCaster 3761 — 5y
Ad

Answer this question