How to change the death sound on the fly

Everything I search up is only able to do it one time so I’m posting it here

I want to add custom death sounds that the player can swap by buying them but with the current code I have now there is no sound, I have also tried putting it in brackets and quotes but it has the same result

equipped.Changed:Connect(function(value)
	if value == "Default" then
		SOUND_DATA.Died = {SoundId = DeathEffects[1]}
	else
		-- If can't find make it default
		SOUND_DATA.Died = {SoundId = DeathEffects[1]}
	end
end)

I have added custom code under the SOUND_DATA table in RbxCharacterSounds local script in StarterPlayerScripts

2 Likes

Link to post on how to change death sound.

Link to IntValue

You could try using an IntValue to change the death sounds on the fly using a local script. Then you could make it change a sound file to whatever audio effect you want. Though I haven’t tested if it would work.

To change the audio file you could link it towards a file inside either workspace or replicastorage.

SoundId = game.workspace.AddWhateverHere

1 Like

I found out that the problem was that there was a problem with the code earlier on that made it confused on where the “equipped” variable was, my mistake.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.