Sound wont play when monster spawns

Can someone tell me why this script wont play a sound when the monster spawns. The script controls monster spawns after they get killed. I want it to play a sound when the pop up.

local serverStorage = game:GetService("ServerStorage")
local barbarian = serverStorage:WaitForChild("Goblin"):Clone()

barbarian.HumanoidRootPart.Position = script.Parent.Position

local spawnpos = barbarian:WaitForChild("SpawnPosition")
spawnpos.Value = script.Parent.Position
local respawntime = 15

barbarian.Parent = game.Workspace

barbarian.Humanoid.HealthChanged:Connect(function(newHealth)
	local sound = script.Parent.laugh   ------ sound location
	if newHealth <= 0 then
		wait(5)
		barbarian:Destroy()
		wait(respawntime)
		sound:Play()   ----- should play the sound?
		script.Disabled = true
		script.Disabled = false
	end
end)

I put notes in the sounds i am trying to play. I tried moving them all around in the script at different locations and nothing seems to work.

Why is the script being disabled and then enabled again? Maybe this is the issue.

You can just use the Humanoid.Died event rather than checking the health everytime it changes.

That is the issue. It won’t be able to re-enable itself after it is disabled. At least after. It shouldn’t effect the sound any.

1 Like
barbarian.Humanoid.HealthChanged:Connect(function(newHealth)
	local sound = script.Parent.laugh   ------ sound location
    sound.PlayOnRemove = true 
	if newHealth <= 0 then
		task.wait(5)
		barbarian:Destroy()
		task.wait(respawntime)
		-- Sound will automatically play.
        -- ?? Bottom part is what for?
		script.Disabled = true
		script.Disabled = false
	end
end)
-- ALT
barbarian.Humanoid.Died:Connect(function()
    local sound = script.Parent.laugh   ------ sound location
    sound.PlayOnRemove = true
    task.wait(5)
    barbarian:Destroy()
    task.wait(respawntime)
    --script.Disabled = true
    --script.Disabled = false
end)

I made this script a long time ago and cant remember why disabling it worked but it does. If I take the disable out the monster will not spawn after it gets killed.