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

Randomization between several death sounds?

Asked by 10 years ago

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

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

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.

0
I tried it. No luck, if I reset or have an AI kill me, I just hear the same generic death sound. RobloxBossk 20 — 10y
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. Perci1 4988 — 10y
Ad

Answer this question