lobbymusic = script:WaitForChild("lobbymusic")
print("Got table 'Lobbymusic!'")
local replicatedstorage = game:GetService("ReplicatedStorage")
print("Got replicatedstorage!")
local statustag = replicatedstorage:WaitForChild("statustag")
print("Got statustag!")
local electro = script.lobbymusic:WaitForChild("electro")
print("Got electro!")
local motivational = script:WaitForChild("motivational")
print("Got m1!")
local rogue = script:WaitForChild("rogue")
print("Got m2!")
local threestep = script:WaitForChild("threestep")
print ("Got threestep!")
local playing = script:WaitForChild("musicplaying")
print("Got boolean 'Playing!'")
lobbytable = lobbymusic:GetChildren()
print("Got children of table 'Lobbymusic!'")
while true do
wait()
if playing.Value == true then
print("Music is already playing!")
elseif playing.Value == false then
if statustag.Value == "Error: Not enough players! Invite a friend to start playing!" or statustag.Value == "The game will start soon" and playing.Value == false then
playmusic = lobbytable[math.random(1,#lobbytable)]:Play()
for vol = 0,0.6,0.05 do
wait(0.2)
playmusic.Volume = vol
end
end
end
end
This basically puts music into a table and then randomly plays one. For line 29 when I try to adjust its volume, however, it gives me this error: Line 29: Attempt to index global 'playmusic,' a nil value

2 comments
Shouldn't you add a SoundId?
There is a sound ID. Even without a sound ID, it wouldn't return that error.