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

How can I make a mute GUI button script with the music script i already have set up?

I have this music script that i want to specifically keep because it allows me to edit the playback speed and i haven't seen a script that allows me to the that like the one i have right now. and i'm in the need of a mute button script as said in the title. here is my music script here is a link to a screen shot that shows how my music guis and stuff is set up https://gyazo.com/50c7b9bfa0d26aea789b12008ebb1384 https://gyazo.com/df66581990520b9f3bd9ab12dc82b6f9

while true do
	script:WaitForChild("GIRLS NEED LOVE"):Play()
	script.Parent.Text = script:WaitForChild("GIRLS NEED LOVE").Name
	wait(115)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("GIMME LOVE"):Play()
	script.Parent.Text = script:WaitForChild("GIMME LOVE").Name
	wait(125)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("LOVE SONGS (BONUS)"):Play()
	script.Parent.Text = script:WaitForChild("LOVE SONGS (BONUS)").Name
	wait(155)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("BLINDING LIGHTS"):Play()
	script.Parent.Text = script:WaitForChild("BLINDING LIGHTS").Name
	wait(205)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("PLAY DATE"):Play()
	script.Parent.Text = script:WaitForChild("PLAY DATE").Name
	wait(185)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("IN YOUR EYES"):Play()
	script.Parent.Text = script:WaitForChild("IN YOUR EYES").Name
	wait(240)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("SAVAGE REMIX"):Play()
	script.Parent.Text = script:WaitForChild("SAVAGE REMIX").Name	
	wait(245)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("CIRCLES"):Play()
	script.Parent.Text = script:WaitForChild("CIRCLES").Name
	wait(195)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("BLUE JEANS"):Play()
	script.Parent.Text = script:WaitForChild("BLUE JEANS").Name
	wait(155)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("RAIN ON ME"):Play()
	script.Parent.Text = script:WaitForChild("RAIN ON ME").Name
	wait(170)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("FALLING DOWN"):Play()
	script.Parent.Text = script:WaitForChild("FALLING DOWN").Name
	wait(205)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("SHOW ME HOW"):Play()
	script.Parent.Text = script:WaitForChild("SHOW ME HOW").Name
	wait(125)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("NEEDY"):Play()
	script.Parent.Text = script:WaitForChild("NEEDY").Name
	wait(155)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("EVERYTHING I WANTED"):Play()
	script.Parent.Text = script:WaitForChild("EVERYTHING I WANTED").Name
	wait(240)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("STREETS"):Play()
	script.Parent.Text = script:WaitForChild("STREETS").Name
	wait(230)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("WORLDSTAR MONEY (INTERLUDE)"):Play()
	script.Parent.Text = script:WaitForChild("WORLDSTAR MONEY (INTERLUDE)").Name
	wait(115)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("NO TIME TO DIE"):Play()
	script.Parent.Text = script:WaitForChild("NO TIME TO DIE").Name
	wait(250)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("RUN"):Play()
	script.Parent.Text = script:WaitForChild("RUN").Name
	wait(210)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
		script:WaitForChild("SANCTUARY"):Play()
	script.Parent.Text = script:WaitForChild("SANCTUARY").Name
	wait(155)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
	    script:WaitForChild("GANGSTA"):Play()
	script.Parent.Text = script:WaitForChild("GANGSTA").Name
	wait(75)
	script:WaitForChild("loading."):Play()
	script.Parent.Text = script:WaitForChild("loading.").Name
	wait(1)
	script:WaitForChild("loading.."):Play()
	script.Parent.Text = script:WaitForChild("loading..").Name
	wait(1)
	script:WaitForChild("loading..."):Play()
	script.Parent.Text = script:WaitForChild("loading...").Name
	wait(1)
end

1 answer

First of all, this script can be way shorter; (skip past all of this code for the answer to your question

local Songs = {}

for _,sound in pairs(script:GetChildren()) do -- inserts all of the sounds into a table
	if sound:IsA("Sound") then
		table.insert(Songs,sound)
	end
end

Now you have a table containing all of your sound objects, now for playing them in your loop.

local ChosenSong = 0
while true do
	ChosenSong = ChosenSong + 1
	if ChosenSong > #Songs then ChosenSong = 1 end -- checks if the chosen song number is larger than the amount of songs you have and resets it

	local Sound = Songs[ChosenSong] -- indexes the chosen song
	Sound:Play()
	Sound.Ended:Wait() -- fires a Wait when the song ends
	for i = 1,3 do -- easier way to do a ". . ."
		script.Parent.Text = "Loading"
		for dot = 1,i do
			script.Parent.Text = script.Parent.Text.."."
		end
		wait(1)
	end
	script.Parent.Text = "Loading"
end

Now, that we're done with that, let's give you an answer

PauseButton.Activated:Connect(function()
	for _,song in pairs(script:GetChildren())
		if song:IsA("Sound") and song.IsPlaying then
			song.IsPlaying = false -- sound:Pause() is also an option, this pauses the current sound playing
		end
	end
end)

Hope this helped you out

2 comments

0

how can i make the script change the parents text to whatever the sound is named? and for some reason the mute button isnt working. that'll be all after that tho thank you<3

0

hello?

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