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

Music not stopping sound?

Asked by
iFlusters 355 Moderation Voter
8 years ago

Having trouble for a while now:

if game.Workspace:FindFirstChild("Music") then
    game.Workspace:WaitForChild("Music"):Stop()
    game.Workspace:FindFirstChild("Music"):remove()
end

I added prints inbetween and they both ran ("Stopped"), ("Removed") yet the sound continued to play..? before their was a Sound called 'Instance' in workspace and it was removed but wasn't stopped, not sure why it's not stopping.

This is how it's created:

function CreateSound()
    Music = Instance.new("Sound")
    Music.Name = "Music"
    Music.Looped = false
    Music.Parent = game.Workspace
    Music.PlayOnRemove = false
end
0
Your conditional checks to see if Music exists, that's okay, but then your WaitForChild does what it says which means it waits for a child called "Music" to be added to workspace. It already exists so it won't work. FearMeIAmLag 1161 — 8y

Answer this question