Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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
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. Ascarson4 138 — 3y
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 jtath120 2 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Can you show me more how the script works?

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. jtath120 2 — 3y
0
now how long is the song? Clervate 15 — 3y
0
also it is meant to loop and time is 107.154 secs. jtath120 2 — 3y
0
ok ill see if I can fix it Clervate 15 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
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.

0
justinwe I put it in but it doesn't work. jtath120 2 — 3y

Answer this question