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

I need help with a sound script meant to play when visible and stop when not visible?

what can I do to fix this? it does not work. pretty much what my goal is for it to play the song until the main menu is not visible.I double-checked and the names for everything are right

local song = game.Workspace.MainMenuTheme
local main = game.StarterGui.Main

repeat
	song:Play()
until main.Start.Visible == false

repeat
	song:Play()
until main.Voting.Visible == false

repeat
	song:Stop()
until main.Start.Visible == true

2 comments

0

How long is your song? And also, repeat. . .until will just execute song:Play() repeatedly without delay, meaning your song is being spam restarted.

0

I tried if main.start.visible then and then song:play() next line didn't fix it and the song is needed to be looped as well but then stop looped when it done

2 answers

Can you show me more how the script works?

4 comments

0

Pretty much it is meant to play the song while menu stat and voting is open but when the cutscene starts the song is meant to stop. Thats the main bit and only bit but it isn't working.

0

now how long is the song?

0

also it is meant to loop and time is 107.154 secs.

0

ok ill see if I can fix it

main.Start:GetPropertyChangedSignal("Visible"):Connect(function()
	if main.Start.Visible == false then
		song:Stop()
	elseif main.Start.Visible == true then
		song:Play()
	end
end

Whenever visibility changes, the function will fire and Stop/play the song depending if it is visible or not.

1 comment

0

justinwe I put it in but it doesn't work.

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