Switching your Humanoid Died Sound

I’m surprised that a forum search for “Switching Roblox CoreSounds” turned up 0 results in the Tutorials section. So here’s a quick and dirty tutorial to help fix that.

  1. In your workplace, create a LocalScript named RbxCharacterSounds. Place this script in StarterPlayer → StarterPlayerScripts.

  2. Copy Roblox’s original CharacterSounds script into the new LocalScript object you just made.

This foldout contains a slightly edited copy of the default sounds script if you don't know where to find it
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local AtomicBinding = require(script:WaitForChild("AtomicBinding"))

local function loadFlag(flag: string)
	local success, result = pcall(function()
		return UserSettings():IsUserFeatureEnabled(flag)
	end)
	return success and result
end

local FFlagUserAtomicCharacterSoundsUnparent = loadFlag("UserAtomicCharacterSoundsUnparent")

local SOUND_DATA : { [string]: {[string]: any}} = {
	Climbing = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
	},
	Died = {
		SoundId = "rbxasset://sounds/uuhhh.mp3",
	},
	FreeFalling = {
		SoundId = "rbxasset://sounds/action_falling.mp3",
		Looped = true,
	},
	GettingUp = {
		SoundId = "rbxasset://sounds/action_get_up.mp3",
	},
	Jumping = {
		SoundId = "rbxasset://sounds/action_jump.mp3",
	},
	Landing = {
		SoundId = "rbxasset://sounds/action_jump_land.mp3",
	},
	Running = {
		SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3",
		Looped = true,
		Pitch = 1.85,
	},
	Splash = {
		SoundId = "rbxasset://sounds/impact_water.mp3",
	},
	Swimming = {
		SoundId = "rbxasset://sounds/action_swim.mp3",
		Looped = true,
		Pitch = 1.6,
	},
}

-- map a value from one range to another
local function map(x: number, inMin: number, inMax: number, outMin: number, outMax: number): number
	return (x - inMin)*(outMax - outMin)/(inMax - inMin) + outMin
end

local function playSound(sound: Sound)
	sound.TimePosition = 0
	sound.Playing = true
end

local function shallowCopy(t)
	local out = {}
	for k, v in pairs(t) do
		out[k] = v
	end
	return out
end

local function initializeSoundSystem(instances)
	local player = instances.player
	local humanoid = instances.humanoid
	local rootPart = instances.rootPart

	local sounds: {[string]: Sound} = {}

	-- initialize sounds
	for name: string, props: {[string]: any} in pairs(SOUND_DATA) do
		local sound: Sound = Instance.new("Sound")
		sound.Name = name

		-- set default values
		sound.Archivable = false
		sound.RollOffMinDistance = 5
		sound.RollOffMaxDistance = 150
		sound.Volume = 0.65

		for propName, propValue: any in pairs(props) do
			(sound :: any)[propName] = propValue
		end

		sound.Parent = rootPart
		sounds[name] = sound
	end

	local playingLoopedSounds: {[Sound]: boolean?} = {}

	local function stopPlayingLoopedSounds(except: Sound?)
		for sound in pairs(shallowCopy(playingLoopedSounds)) do
			if sound ~= except then
				sound.Playing = false
				playingLoopedSounds[sound] = nil
			end
		end
	end

	-- state transition callbacks.
	local stateTransitions: {[Enum.HumanoidStateType]: () -> ()} = {
		[Enum.HumanoidStateType.FallingDown] = function()
			stopPlayingLoopedSounds()
		end,

		[Enum.HumanoidStateType.GettingUp] = function()
			stopPlayingLoopedSounds()
			playSound(sounds.GettingUp)
		end,

		[Enum.HumanoidStateType.Jumping] = function()
			stopPlayingLoopedSounds()
			playSound(sounds.Jumping)
		end,

		[Enum.HumanoidStateType.Swimming] = function()
			local verticalSpeed = math.abs(rootPart.AssemblyLinearVelocity.Y)
			if verticalSpeed > 0.1 then
				sounds.Splash.Volume = math.clamp(map(verticalSpeed, 100, 350, 0.28, 1), 0, 1)
				playSound(sounds.Splash)
			end
			stopPlayingLoopedSounds(sounds.Swimming)
			sounds.Swimming.Playing = true
			playingLoopedSounds[sounds.Swimming] = true
		end,

		[Enum.HumanoidStateType.Freefall] = function()
			sounds.FreeFalling.Volume = 0
			stopPlayingLoopedSounds(sounds.FreeFalling)
			playingLoopedSounds[sounds.FreeFalling] = true
		end,

		[Enum.HumanoidStateType.Landed] = function()
			stopPlayingLoopedSounds()
			local verticalSpeed = math.abs(rootPart.AssemblyLinearVelocity.Y)
			if verticalSpeed > 75 then
				sounds.Landing.Volume = math.clamp(map(verticalSpeed, 50, 100, 0, 1), 0, 1)
				playSound(sounds.Landing)
			end
		end,

		[Enum.HumanoidStateType.Running] = function()
			stopPlayingLoopedSounds(sounds.Running)
			sounds.Running.Playing = true
			playingLoopedSounds[sounds.Running] = true
		end,

		[Enum.HumanoidStateType.Climbing] = function()
			local sound = sounds.Climbing
			if math.abs(rootPart.AssemblyLinearVelocity.Y) > 0.1 then
				sound.Playing = true
				stopPlayingLoopedSounds(sound)
			else
				stopPlayingLoopedSounds()
			end
			playingLoopedSounds[sound] = true
		end,

		[Enum.HumanoidStateType.Seated] = function()
			stopPlayingLoopedSounds()
		end,

		[Enum.HumanoidStateType.Dead] = function()
			stopPlayingLoopedSounds()
			playSound(sounds.Died)
		end,
	}

	-- updaters for looped sounds
	local loopedSoundUpdaters: {[Sound]: (number, Sound, Vector3) -> ()} = {
		[sounds.Climbing] = function(dt: number, sound: Sound, vel: Vector3)
			sound.Playing = vel.Magnitude > 0.1
		end,

		[sounds.FreeFalling] = function(dt: number, sound: Sound, vel: Vector3): ()
			if vel.Magnitude > 75 then
				sound.Volume = math.clamp(sound.Volume + 0.9*dt, 0, 1)
			else
				sound.Volume = 0
			end
		end,

		[sounds.Running] = function(dt: number, sound: Sound, vel: Vector3)
			sound.Playing = vel.Magnitude > 0.5 and humanoid.MoveDirection.Magnitude > 0.5
		end,
	}

	-- state substitutions to avoid duplicating entries in the state table
	local stateRemap: {[Enum.HumanoidStateType]: Enum.HumanoidStateType} = {
		[Enum.HumanoidStateType.RunningNoPhysics] = Enum.HumanoidStateType.Running,
	}

	local activeState: Enum.HumanoidStateType = stateRemap[humanoid:GetState()] or >humanoid:GetState()

	local stateChangedConn = humanoid.StateChanged:Connect(function(_, state)
		state = stateRemap[state] or state

		if state ~= activeState then
			local transitionFunc: () -> () = stateTransitions[state]

			if transitionFunc then
				transitionFunc()
			end

			activeState = state
		end
	end)

	local steppedConn = RunService.Stepped:Connect(function(_, worldDt: number)
		-- update looped sounds on stepped
		for sound in pairs(playingLoopedSounds) do
			local updater: (number, Sound, Vector3) -> () = loopedSoundUpdaters[sound]

			if updater then
				updater(worldDt, sound, rootPart.AssemblyLinearVelocity)
			end
		end
	end)

	local function terminate()
		stateChangedConn:Disconnect()
		steppedConn:Disconnect()

		if FFlagUserAtomicCharacterSoundsUnparent then
			-- Unparent all sounds and empty sounds table
			-- This is needed in order to support the case where initializeSoundSystem might be called >more than once for the same player,
			-- which might happen in case player character is unparented and parented back on server >and reset-children mechanism is active.
			for name: string, sound: Sound in pairs(sounds) do
				sound:Destroy()
			end
			table.clear(sounds)
		end
	end

	return terminate
end

local binding = AtomicBinding.new({
	humanoid = "Humanoid",
	rootPart = "HumanoidRootPart",
}, initializeSoundSystem)

local playerConnections = {}

local function characterAdded(character)
	binding:bindRoot(character)
end

local function characterRemoving(character)
	binding:unbindRoot(character)
end

local function playerAdded(player: Player)
	local connections = playerConnections[player]
	if not connections then
		connections = {}
		playerConnections[player] = connections
	end

	if player.Character then
		characterAdded(player.Character)
	end
	table.insert(connections, player.CharacterAdded:Connect(characterAdded))
	table.insert(connections, player.CharacterRemoving:Connect(characterRemoving))
end

local function playerRemoving(player: Player)
	local connections = playerConnections[player]
	if connections then
		for _, conn in ipairs(connections) do
			conn:Disconnect()
		end
		playerConnections[player] = nil
	end

	if player.Character then
		characterRemoving(player.Character)
	end
end

for _, player in ipairs(Players:GetPlayers()) do
	task.spawn(playerAdded, player)
end
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerRemoving:Connect(playerRemoving)
  1. Upload a death sound for your game to use. Then go to the Details page for that sound (which can be done by clicking on its title in the website.

  2. Copy the first long number from the browser URL, directly after the “library” word.

For your convenience, and to demonstrate, here’s the URL I’m using: https://www.roblox.com/library/1277215697/Cuphead-Death-Sound-Effect – and the text that I want to copy is the number 1277215697.

Fair warning: Roblox’s Audio Privacy update made it so you can’t use any audio that hasn’t explicitly given your experience permission to use it. The old URL remains so you can see the exact text you need to copy, but you will not be able to use the sound effect I’ve linked here.

  1. Going back to Studio, locate the local variable containing the Died sound effect, on line 24.

  2. Replace sounds/uuhhh.mp3 with the number you’ve copied.

You are good to go! Your CoreSound has been changed, and you will no longer hear the old ‘guh’ death.

16 Likes

I would recommend moving this to #resources:community-resources but that’s just me.

1 Like

I feel this is a resource that is too specific for Community Resources. The intro text that gets copied into the text box mentions that if your resource is considered “too specific”, you should consider posting to another forum category.

I suspect a topic about switching out your death sound – moreover, one that doesn’t offer any downloads or additional resources – is too specific to warrant a post in Community Resources.

4 Likes

In my personal opinion, I would just write code to play my custom sound when the player died. Something like this

script.Parent.Humanoid.Died:Connect(function()
      script.Parent.CustomDeath:Play()
end)

I bet this is because of that forum ad for Tammy Tallarco isn’t it?

4 Likes

This is a replacement for Roblox’s core sound script. Since core script replacements included with the place always override the default sound script, you will always receive the intended behavior come hell or high weather.

Also note that your method is playing a custom death sound on top of whatever sound Roblox specifies when your Humanoid health reaches 0.

2 Likes

This is a tutorial not a resource. The OP isn’t just giving the resource away, they’re teaching you.

2 Likes

And when the update rolls out removing the uuhhh.mp3, it’ll probably get removed from the files as well.

1 Like

That’s kind of the point of this tutorial. It teaches you how to replace the core sounds such as uuhhh.mp3 so that you can use whatever you want, including possibly your own version of uuhhh.mp3, and I just happen to teach you using the death sound. Do note that you could use this to replace your oof sound with one of Spammy Spammarico’s replacements ahead of time, if you’d like to test how they feel like in game.

2 Likes

so make sure to back it up on your computer and then upload to roblox!

Possibly they’ll remove all the re-uploads during the first couple of months/weeks but after that I’m sure they’ll stop

1 Like

Seems like a good time to put this thread back to the top of the forums for a bit.

5 Likes

It’s been a while, but figured I’d update the CoreSound copy in this post. Roblox implemented a few new functions that you’d go without if you use the old copy, so I figured I’d at least make an attempt to keep this topic up to date.