Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

When boss dies, sound wont stop playing. Could somebody help fix the script for me?

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)

2 comments

0

Add a print after humanoid.Died:connect(function(), see if its printing

0

I wrote, print("printed this message") underneath humanoid.Died:connect(function() and it prints out in console when the sound plays. Any other suggestions?

2 answers

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.

2 comments

0

Sorry for late reply, no the script does not work. I don't think task.wait(1) is going to do anything except from changing the wait time.

0

Yeah, I know but I added a end at the end as a local function ALWAYS end with a end

fixed it myself by making my own music:Stop() function and the function deletes the sound after its played.

This discussion is preserved as it was. New answers, comments, and votes are closed.