How do you change the death sound?

my script is not working. all it does is get the location of the death sound and change it to something else

local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")

HumanoidRootPart:WaitForChild("Died").SoundId = script:WaitForChild("Sound").SoundId

why is it not working and how do you change the death sound?

7 Likes

test the game, check workspace if Humanoid.Died exists

4 Likes

yes it is there it exists and i have no idea why this is not working

2 Likes

…are you sure the audio is named “Sound”

it seems like you’re waiting for an object that is a sound in which you’re doing it incorrectly.

WaitForChildOfClass isn’t a feature yet but has been asked for:

As an alternative, you can use FindFirstChildOfClass or just change “Sound” to the name of the sound you want to act as the replacement.

I had copy pasted your script to a new studio place and it worked without issue

1 Like

“Sound” is the name of the sound that is in the script so thats not the problem and nothing prints in the output at all

1 Like

Since using your script in a new place worked for me, can you try that as well to see if its because of where you’re using it or something else

also may we see the script and its hierarchy if that’s the case? just to completely confirm that everything is placed correctly

I can’t see the issue here since I can’t seem to reproduce it

Also also, try put a print statement at the end of your script. if nothing is being printed then something is keeping the script back. Likely one one of the WaitForChilds.
image
My attempt did return with a print statement, check if yours does as well or if something prevents it

1 Like

i put the exact same script in StarterCharacterScripts

1 Like

Make sure this is a local script. The sounds in the root part are created locally in RbxCharacterSounds, therefore they don’t exist on the server.

2 Likes

Can you send a screenshot of the hierarchy so we can see if everything is correct? Like @fellow_meerkat said, you may be trying to use a server script to access something that’s local. or, you could be getting an infinite yield. the script itself isn’t the issue but you’re likely getting something incorrect with your hierarchy which we haven’t seen yet

image
Given what you have said, it should look like this. The only variable we don’t know about is the script itself and whether its local or not

1 Like

Image

1 Like

I see, real quick since this wasn’t specified: Does the default death sound still play or does nothing play?

1 Like

nothing plays char char char char char limit

1 Like

If nothing is playing, then the audioID may be invalid, private or was removed by roblox. If you save the current ID somewhere and then replace the SoundId of the “Sound” object to another sound then check if it works. if it does then the sound you were trying to use won’t work.

You can try using rbxassetid://9118467835 for example since this is what I used to test if the script was working on my side, you should hear a sound of a robot whir / alarm

1 Like

Changing roblox character sounds makes the sound script assume you want to turn all of them off. You’ll need to make a custom character sound script for this to work!

1 Like

Are you sure? I’ve just implemented the same script they used, the only difference being what sound we used and I haven’t encounted such a thing

1 Like

It’s just what I’ve experienced in the past, it may not be true anymore.

1 Like

I’d assume you are trying to play a death sound whenever the player dies.
Can’t you just do something simple as adding a script inside of StarterCharacterService and just type this in? (Add your death sound inside of the script)

local Character = script.Parent
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

Character:FindFirstChildWhichIsA("Humanoid").Died:Connect(function()
	local Sound = script:WaitForChild("DeathSound"):Clone()
	Sound.Parent = HumanoidRootPart
	Sound:Play()
end)
1 Like

It could be that Died is already a event so try to change the name of the sound.

1 Like

That’s simply because that’s not how you change the character sounds.

  1. Playtest the game
  2. In the Explorer, go to Players > your player > PlayerScripts > RbxCharacterSounds
  3. Copy the RbxCharacterSounds (LocalScript)
  4. Stop the game
  5. Paste the LocalScript into StarterPlayer > StarterPlayerScripts
  6. Go into the script and change the sound id to your desired one in Line 22
8 Likes

I should have read all the messages. I just saw a picture where you are using a LocalScript. Well, I guess that’s my mistake then. But I guess I will still let my post be in here

You are probably using a ServerScript. You should use a LocalScript instead because the sounds inside the HumanoidRootPart only exist on the client. That means a ServerScript can’t have access to these sounds (Except if you use a RemoteEvent I guess, but it would be better to use a LocalScript instead).

If we switch to the ServerSide while testing the game, …
With this button
image

then you can see that the sounds don’t exist on the ServerSide, so a ServerScript is kinda useless here.
image

If you go to the ClientSide again you can see that the sounds are there again.
image

image

So try using a LocalScript. It seems to work fine for me

Also it’s better to use this instead:

local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")

HumanoidRootPart:WaitForChild("Died").SoundId = script:FindFirstChild("Sound").SoundId

The third WaitForChild command is replaced with FindFirstChild. That’s because the sound already is inside the script from the beginning.

(The post above mine should work too)

2 Likes