I've been trying to make a script for my game that makes a Sound/Music play when a frame is visible and it will stop when it's Invisible, I have attempted to make the script on my own but since I'm a beginner I don't know how...
I've put the script below (excuse the clutter.) Any help would be appreciated. :)
--Script--
local Mapvote = script.Parent.Parent local music = script.Parent local musicPlaying = false local audioID = 4814920271 local sound = Instance.new("Sound", music) sound.SoundId = 'rbxassetid://'..audioID if Mapvote.Visible == true then if(musicPlaying == false) then sound:Play() musicPlaying = true else sound:Stop() musicPlaying = false end end
I think all you have to do is put it in a loop.
local Mapvote = script.Parent.Parent local music = script.Parent local musicPlaying = false local audioID = 4814920271 local sound = Instance.new("Sound", music) sound.SoundId = 'rbxassetid://'..audioID while wait(0.2) do if Mapvote.Visible == true then if(musicPlaying == false) then sound:Play() musicPlaying = true else sound:Stop() musicPlaying = false end end end