Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script doesn't work in online mode, only studio mode?

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

1 comment

0

Press F9 in game, check for errors, and tell us what it says.

1 answer

✓ Accepted answer

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")

4 comments

2

Thanks! Helped a lot!

0

Theres an accept answer button to the right of all answers on your questions, click it if it answered your question.

0

Can't find the button?

0

Answered by funyun 80, 50 minutes ago, accept answer, report to staff. It's on the right of this comment section.

This discussion is preserved as it was. New answers, comments, and votes are closed.