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

music off button wont work anymore because of lines 11 - 18 or something else?

local music = game.Workspace.BGM

script.Parent.MouseButton1Click:Connect(function()
	if music.Volume == 0 then
		music.Volume = 1
	else
		music.Volume = 0
		
while music.Volume == 0
do
	script.Parent.Image = "rbxassetid://5095895372"
	script.Parent.MouseButton1Click (function()
		script.Parent.Image = "rbxassetid://5034216966"
		  end
              end
	end
end)

This is a LocalScript inside of a ImageButton inside of a ScreenGui inside of StarterGui

What it is supposed to do is when I press the ImageButton it turns the sound "BGM" off and turns the ImageButton to another Image

1 answer

Here is the fixed code:

local music = game.Workspace.BGM

script.Parent.MouseButton1Click:Connect(function()
    if music.Volume == 0 then
        music.Volume = 1
	script.Parent.Image = "rbxassetid://5034216966"
    else
        music.Volume = 0
	script.Parent.Image = "rbxassetid://5095895372"
	end
end)

Hope this helps!

8 comments

0

an error accours at line 10: expecting end to close function at line 3

0

Sorry, just put a ) after the end on line 10.

0

oh ok

0

huh still does not work

0

any errors?

0

does not say

0

actually, it says Expected identifier when parsing expression got')'

0

I edited my script, it should work now. :)

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