I know this might sound silly, since it's such a simple script. But I was trying to create "Toggle Radio" like After the Flash, and I thought this code would work, but it doesn't stop the sound or show any errors in the Developer Console. Here's my code:
local Sound1 = script.Parent.TimeAndTimeAgain -- References the sound script.Parent.MouseButton1Down:Connect(function() -- Detects when clicked, if so commences these events if Sound1.Playing == false then -- If the sound isn't playing, it plays the sound Sound1:Play() else Sound1:Stop() -- If the sound is playing, it stops the sound end end)
Thanks!
Try this
local Sound1 = Instance.new("Sound") Sound1.SoundId = "rbxassetid://1837324424" Sound1.Parent = script.Parent script.Parent.MouseButton1Down:Connect(function() -- Detects when clicked, if so commences these events if Sound1.IsPlaying == false then -- If the sound isn't playing, it plays the sound Sound1:Play() else Sound1:Stop() -- If the sound is playing, it stops the sound end end)
Apparently, the Play and Stop() function just looped??? I'm so confused about how it was looping. But anyway, I got it fixed. Thanks for your help!