Hello, I made a script so when a boss spawns and it dies, a victory music plays. The music wont stop though. any help please? I want it to play once. would appreciate any help
(server script and not a local one)
local function spawnEnemy(character,cf) local music = game.Workspace.music local npc = character:Clone() local humanoid = npc.Humanoid local torso = npc.Torso npc.Parent = workspace npc:MakeJoints() torso.CFrame=cf humanoid.Died:connect(function() music.SoundId = "rbxassetid://10807323565" music.PlaybackSpeed = 1 music:Stop() wait(1) npc:Destroy() end)
local function spawnEnemy(character,cf) 02 local music = game.Workspace:WaitForChild("music") 03 local npc = character:Clone() 04 local humanoid = npc.Humanoid 05 local torso = npc.Torso 06 npc.Parent = workspace 07 npc:MakeJoints() 08 torso.CFrame=cf 09 humanoid.Died:Connect(function() task.wait() 10 music.SoundId = "rbxassetid://10807323565" 11 music.PlaybackSpeed = 1 12 music:Stop() 13 task. wait(1) 14 npc:Destroy() 15 end) end
I'm not sure if this will work, but at least try.
fixed it myself by making my own music:Stop() function and the function deletes the sound after its played.