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.
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.