Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My ScreenGUI Button wont work?

Asked by
CjInc 5
9 years ago

So, I made a button that mutes in-game music if clicked...well...it's supposed to, anyways. The BUTTON works, but the function doesn't. I have a feeling I need to remake the script that mutes music. Any tips? Thanks!

Here's the script.

local Gui = script.Parent
local Player = script.Parent.Parent.Parent
local button = script.Parent.MouseButton1Clicked
local Char = Player.Character

Gui.ButtonMouse1Clicked:connect(button)
function button ()
ToggleMute ()

end

ToggleMute = Gui.MouseButton1Clicked:connect()
1
Please provide your script so we can address your issues and help you fix it. Not make an entirely new script for you. minikitkat 687 — 9y

1 answer

Log in to vote
0
Answered by
TopDev 0
9 years ago
p = game.Players.LocalPlayer
sound = p.Backpack:WaitForChild("LobbyMusic")



script.Parent.MouseButton1Click:connect(function()
    if sound.Volume == 1 then
    sound.Volume = 0
    else
    sound.Volume = 1
    end
end)

Here is a extremely simple script I made awhile ago. Add the music to the StarterPack and change the name on line 2 where it says "LobbyMusic" to whatever the name of the sound is called.

Replace this script with your current. Make sure you are using a localscript

0
Thank you, very much! CjInc 5 — 9y
Ad

Answer this question