I was making a script with a SurfaceGUI button that would play/stop music if it was clicked on. It tried the below script but it didn't work.
local button = script.Parent
local sound = button:WaitForChild('Sound')
local function onButtonClick()
if sound.IsPlaying then
sound:Stop()
else sound:Play()
end
end
button.MouseButton1Click:connect(onButtonClick)
What did I do wrong?

2 comments
First off, are you using a local script?
Yes, I am using a local script, but the button is visible to the entire server (it's on a brick).