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

Randomization between several death sounds?

Somebody was trying to help me randomize custom death sounds and gave me this script.

IDs = {130965811, 131045862, 131045876}

game.Players.PlayerAdded:connect(function(player)
repeat wait() until player.Character
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function(human)
sound = "http://www.roblox.com/asset/?id="..tostring(IDs[math.random(#IDs)])
sound:Play()
end)
end)
end)

However, it doesn't work. Is there a way to salvage this?

1 answer

Change (IDs[math.random(#IDs)]) to (IDs[math.random(1,#IDs)])

I'm pretty sure you must give math.random() a number to start with, as well as end with.

2 comments

0

I tried it. No luck, if I reset or have an AI kill me, I just hear the same generic death sound.

0

I just looked on the wiki. It looks like you have to create a sound as an actual instance. You could also try making the volume louder.

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