I'm trying to make a mute music button and am still quite new to scripting. I've got as far as making the remote event and two scripts needed, but when clicked it mutes the music for everyone rather than the person clicking, can anyone find a way around this?
Gui Button: (LocalScript)
script.Parent.MouseButton1Click:Connect(function() game:GetService("ReplicatedStorage").RemoteEvents.MuteMusic:FireServer() end)
Receiving Script: (Script)
game:GetService("ReplicatedStorage").RemoteEvents.MuteMusic.OnServerEvent:Connect(function(Player) script.Parent.Volume = "0" end)
If you are trying to locally mute the music, you don't have to use RemoteEvent
because the change doesn't have to be replicated to everyone. Which means that you can directly set the volume of the sound to 0 from local script. Also, I think you can add 1 if statement to check if the sound is on, turn it off and vice versa.
local soundOn = true script.Parent.MouseButton1Down:Connect(function()) if soundOn == true then workspace.Sound.Volume = 0 soundOn = false elseif soundOn == false then workspace.Sound.Volume = 1 soundOn = true end end)