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

Can anyone make this local? details below

Asked by
u1v6 22
5 years ago

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)
0
the code kinda cut off sorry u1v6 22 — 5y

1 answer

Log in to vote
0
Answered by
Yuuwa0519 197
5 years ago
Edited 5 years ago

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)
0
I was mainly using remote events for security but I will be sure to give your way a go tyy u1v6 22 — 5y
Ad

Answer this question