Hello ! i made a script so that when a player joins he’ll get music and he can deactivate or reactivate but the problem is that it doesn’t work so if someone can help me that would be great!
here is the script
local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true
script.Parent.MouseButton1Click:Connect(function()
if playing == true then
music.Playing = false
button.Text = “”
playing = false
else
music.Playing = true
button.Text = “”
playing = true
end
end)
ofc My sound name is “Dion” and i put the script on local script
Wait so is script.Parent.Mute supposed to do the toggling?
If so, change script.Parent.MouseButton1Click to script.Parent.Mute.MouseButton1Click, or alternatively, button.MouseButton1Click
local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true
button.MouseButton1Click:Connect(function()
if playing == true then
music.Playing = false
button.Text = “:mute:”
playing = false
else
music.Playing = true
button.Text = “:loud_sound:”
playing = true
end
end)
Adding onto this, made it a little more efficient, and I’m sure you can’t modify the Playing property directly.
local music = game.Workspace.Sounds.Dion
local button = script.Parent.Mute
playing = true
button.MouseButton1Click:Connect(function()
if playing then
music:Pause()
button.Text = “:mute:”
else
music:Play()
button.Text = “:loud_sound:”
end
playing = not playing
end)
This should work just fine. It’s a local script, and the button is a TextButton, and it’s referenced properly, right? Can you show us the errors, if any?