My music player won't work when I actually play the game, the GUI doesn't appear and the music doesn't play, but yet when playing solo in studio mode, everything works fine. Why is this? This is a LocalScript in a GUI.
--Passtimed local songs = {"Yeah", "Ok", "I Love You", "Hello"} local display = script.Parent.SongBar local id = script.Parent:WaitForChild("Music") function choosesong() song = songs[math.random(1,#songs)] if song == "Yeah" then id.SoundId = "http://www.roblox.com/asset/?id=248543325" elseif song == "Ok" then id.SoundId = "http://www.roblox.com/asset/?id=250755837" elseif song == "I Love You" then id.SoundId = "http://www.roblox.com/asset/?id=225000651" elseif song == "Hello" then id.SoundId = "http://www.roblox.com/asset/?id=227526622" end end wait(1) print("Song script loaded!") while true do wait(.1) choosesong() display.Text = "Song: " .. song .. "!" id:Play() wait(120) end
Your current error is that "SongBar" needs load before you can do anything with it. Use the WaitForChild method to wait for it.
local display = script.Parent:WaitForChild("SongBar")