How can I put different sounds when you die

I mean it has different

Actually the HumanoidRootPart has a sound object in it named as ‘Died’ which contains the id of the default oof sound.

What you can do is to have the ID’s of your sounds in an array and then randomly pick one of them from it and replace the soundID with the one you want when the player’s character loads (after being dead)

3 Likes

just go into RbxCharacterSounds, and replace the die sound with the SoundId.

Hope this worked!

1 Like

I only want One sound random

how can I do that?

You could use a math.random to keep changing the sounds when the player die

1 Like

Put this inside a localscript in StarterGui

local player = game.Players.LocalPlayer

repeat wait() until player.Character
local character = player.Character
local root = character:WaitForChild("HumanoidRootPart")
local diedSound = root:WaitForChild("Died")

local idArray = {
 "first ID",
  "second ID",
   "third one",
   "and so on..",
}

diedSound.SoundId = idArray[Random.new():NextInteger(1, #idArray)]

EDIT: As per how you want to do…here is a modification

local sounds = game.Workspace.Sounds:GetChildren()
local idArray = {}

for index, object in pairs(sounds) do
    idArray[index] = object.SoundId
end

EDIT : sorry actually I made a mistake. In lua indexing starts from 1 not 0 unlike other OOPs

1 Like

1723uasd123

I want this sounds

This is a example of a script that i made :

local test = nil repeat wait() test = script.Parent:FindFirstChildOfClass("Humanoid") until test ~= nil test.Died:connect(function() local maths = math.random(1,2) maths = math.random(1,2) if maths == 1 then local sound = Instance.new("Sound") sound.Parent = test.Parent.Head sound.SoundId = ""--SoundID sound.Volume = 0.5 sound:Play() else local sound = Instance.new("Sound") sound.Parent = test.Parent.Head sound.SoundId = ""--Another SoundID sound.Volume = 0.5 sound:Play() end end)

And if you use this insert the script into StarterPlayer > StarterCharacterScripts

Oh and sorry about that with the code, it glitched im not sure why…

1 Like

oh, next time give more information in the post, most people dont like to respond post with not so much information about what is the problem.

1 Like
function randomizer(test)
 local sounds = workspace.Sounds:GetChildren()
     local playsound = (sounds[math.random(1, #sounds)])
local clone = playsound:Clone()
    clone.Parent = script.Parent.Head
clone:Play()
end

local test = nil
repeat
wait()
test = script.Parent:FindFirstChildOfClass("Humanoid")
until test ~= nil

test.Died:connect(function()
randomizer(test)
end)

And if you use this insert the script into StarterPlayer > StarterCharacterScripts

1 Like

not sure but I think that math.random() will returns floating point numbers as well…
So I suggest using math.floor(math.random(sounds)) even if it is always recommended to use Random.new():NextInteger(min, max)

1 Like