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

Is This Script Correct? (Song Playing Button)

I created a script in the StarterGui, and the parent of the script is a TextButton, and the parent of that is a ScreenGui, the screengui includes a Sound too. I am trying to make a button that when you click it it plays the song in the sound id. Although it's not working, this is the script of the TextButton. (It's a LocalScript)

Player = game.Players.LocalPlayer
Button = script.Parent
Song = script.Parent.Parent.Song
Playing = false

function PlaySong()
	if (Playing == false) then
		Song:Play()
		Playing = true
	elseif (Playing == true) then
		Song:Stop()
		Playing = false
	end
end

Button.MouseButton1Down:connect(PlaySong)

2 comments

0

Could be a loading issue. Try preloading the song asset.

0

Oh and by the way, I forgot to say, it works when I test in ROBLOX Studio, but not in server

1 answer

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