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

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

Asked by 2 years ago
Edited 2 years ago

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)
0
Add a print after humanoid.Died:connect(function(), see if its printing Jay123abc2 241 — 2y
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? kekemama645 0 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago
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.

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. kekemama645 0 — 2y
0
Yeah, I know but I added a end at the end as a local function ALWAYS end with a end DecentAgent 0 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question