I'm trying to make a local script, where when you press a text button, it plays a sound (looped) and if you click the text button again it will stop the sound
but if the sound is playing and you press a different text button, it will stop sound1 and play sound2
and again if textbutton2 is pressed, it will stop the sound that is playing. and if you press text button1 it will stop sound 2 and play sound 1, and so forth
i was planning on adding more Sounds and textbuttons so i planned on making the for_, value, so it checks if any of the audios are running. instead of using sound 2, so it doesn't get messy in the future
but my script doesn't seem to be working help would be nice. you don't have to help if it looks like a struggle
local player = game.Players.LocalPlayer local character = player.Character if not character or not character.Parent then character = player.CharacterAdded:wait() end wait()
local MainGui = script.Parent local Textbutton1 = MainGui.ScrollingFrame.Dance1 local Textbutton2 = MainGui.ScrollingFrame.Dance2 wait()
---First Dance Textbutton1.MouseButton1Up:Connect(function(Touched)
if Touched then do for _, value in ipairs(character.Head.SongFolder:GetChildren()) do if value:IsA("Sound") then do if value.Playing == false then do --if you click on the first button and none of the sounds are playing, character.Head.SongFolder.Sound1.Playing = true print("Sound playing1")---then it will play sound 1 return end end end end end end end wait() if Touched then do for _, value in ipairs(character.Head.SongFolder:GetChildren()) do if value:IsA("Sound") then do if character.Head.SongFolder.Sound1.Playing == true then do value:Stop() -- if sound 1 is playing and you click on it, it will end all sounds print("Sound playing2") return end end end end end end end wait() if Touched then do for _, value in ipairs(character.Head.SongFolder:GetChildren()) do if value:IsA("Sound") then do if value.Playing == true then do character.Head.SongFolder.Sound1.Playing = true print("Sound playing3") return end end end end end end end
I thought i might ask others instead of just giving up. I've been on this for many hours.