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

Mute/Unmute button not working but no erroring?

Used Local script only

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://2830837614"

sound.Looped = true
sound:Play()
sound.Playing = true
local bool = script.Parent.Changer
bool.Value = true





if bool.Value == true then
	script.Parent.Activated:Connect(function()
		bool.Value = false
		sound.Playing = false
	end)
end



if bool.Value == false then
	script.Parent.Activated:Connect(function()
		bool.Value = true
		sound.Playing = true
	end)
end

2 comments

0

what's the error?

0

no error

2 answers

Try this

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://2830837614"

sound.Looped = true
sound:Play()
sound.Playing = true
local bool = script.Parent.Changer
bool.Value = true





if bool.Value == false then
    script.Parent.Activated:Connect(function()
        bool.Value = false
        sound.Playing = false
    end)
end



if bool.Value == true then
    script.Parent.Activated:Connect(function()
        bool.Value = true
        sound.Playing = true
    end)
end

In your script, since you set the bool as true, the script will run and wait for it to activate until it can set it to false. The script only runs once, and that is your problem;;;;;; i think you can just use the activated event, and then check if the bool is true to change it, so that the script runs multiple times when needed

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://2830837614"

sound.Looped = true
sound:Play()
sound.Playing = true
local bool = script.Parent.Changer
bool.Value = true



script.Parent.Activated:Connect(function() -- activated?
	if bool.Value == true then -- if its true
		bool.Value = false -- change to false
		sound.Playing = false
	else -- if its false
		bool.Value = true
		sound.Playing = true
	end
end)

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