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

Why won't my random death sound script work, what else am I doing wrong?

function addSound()
	
	local sounds = script:GetChildren()
	local chosenSound = sounds[math.random(1, #sounds)]
	local soundCln = chosenSound:Clone()
	soundCln.Parent = script.Parent.Head
	soundCln.Name = "DeathSound"
	soundCln:Play()
	
end

if script.Parent.Humanoid.Health == 0 then 
	addSound()
end

No errors, nothing. The solution is probably just in my face but I'm not too good with scripting yet. Help would be appreciated.

1 answer

✓ Accepted answer

Try doing: script.Parent.Humanoid.Died:Connect(addSound)

2 comments

0

Thanks a bunch, it works like a charm

0

No problem! :P

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