Custom Character Sounds

Hello. I’m currently developing a system in which when the character spawns, all of the default sounds are destroyed and replaced with my own. Each sound has a corresponding function, and I want all players to hear the sounds. However, during testing, the default sounds are not removed. My custom sounds are playing and can be heard by everyone, but I’m having trouble with the player jumping as well. I tried creating a jump event that continuously mutes the sound until the player lands on the ground, but it didn’t work. I am wondering how I can resolve these issues.

local Players = game:GetService("Players")

local function OnCharacterAdded(Character)
	-- [Body] --
	local Humanoid = Character:WaitForChild("Humanoid")
	local Head = Character:WaitForChild("Head")
	local Torso = Character:WaitForChild("Torso")
	-- [Sounds] --
	local DeathSound = Instance.new("Sound")
	local WalkSound = Instance.new("Sound")
	-- [Settings] --
	DeathSound.Name = "Ouch"
	DeathSound.SoundId = "rbxassetid://12222058"
	DeathSound.RollOffMode = Enum.RollOffMode.Linear
	DeathSound.RollOffMinDistance = 2.5
	DeathSound.RollOffMaxDistance = 50
	DeathSound.Parent = Head
	WalkSound.Name = "Footsteps"
	WalkSound.SoundId = "rbxassetid://692614156"
	WalkSound.RollOffMode = Enum.RollOffMode.Linear
	WalkSound.RollOffMinDistance = 5
	WalkSound.RollOffMaxDistance = 35
	WalkSound.Parent = Torso
	WalkSound.Looped = true
	WalkSound.Volume = 0
	WalkSound:Play()
	Humanoid.Died:Connect(function()
		DeathSound:Play()
		WalkSound:Destroy()
	end)
	Humanoid.Running:Connect(function(Speed)
		if Speed > 1 then
			if WalkSound.Volume == 0 then
				task.wait()
				WalkSound.Volume = 0.5
			end
		else
			if WalkSound.Volume == 0.5 then
				task.wait()
				WalkSound.Volume = 0
			end
		end
	end)
end

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(OnCharacterAdded)
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
	for Index,Sound in pairs(HumanoidRootPart:GetChildren()) do
		if Sound:IsA("Sound") then
			Sound:Destroy()
		end
	end
end)

This script is placed under the ServerScriptService with a run context of Legacy. I apologize if this looks a bit messy.

While testing, look under StarterPlayerScripts, you’ll see a script called RbxCharacterSounds. Copy this script, and end testing, now place it in your StarterPlayerScripts. You can now edit this script to instead play your own sounds, instead of manually doing it from another script. You can also change sounds you don’t want to have their ID as nothing.

So basically this will override the sounds?

1 Like

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