I made a music frame, When you click this button it's meant to stop the music It was working fine, until an update from roblox totally screwed it up! Can anyone help me please? This is the code :
local Stoper = script.Parent function onClick() local Sound = game.Workspace.Sound Sound.Volume = 0 Sound.IsPlaying = false Sound.IsPaused = true Sound:Destroy() end Stoper.ClickDetector.MouseClick:connect(onClick)
Thanks for any help!
There's an easier way to stop music. There's a method in Sounds called Stop
, which essentially stops the audio.
Also, you may want to make an if statement to check if the sound actually exists, otherwise the script may return an error and break if the sound is not there.
local Stoper = script.Parent function onClick() local Sound = game.Workspace:FindFirstChild("Sound") if Sound ~= nil then --If sound is not nil then stop and destroy it. Sound:Stop() Sound:Destroy() end end Stoper.ClickDetector.MouseClick:connect(onClick)