Advertisement
AutumnMoon88683

DeathSoundChanger

Feb 18th, 2025 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1.  
  2. local NewDeathSound = 0
  3.  
  4.  
  5. local chara = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
  6.  
  7. local RootPart = chara:FindFirstChild("HumanoidRootPart")
  8.  
  9. local function AddPitchShift(Sound:Sound)
  10.     local Pitches = {0.8,0.9,1,1.1,1.2}
  11.     local pitch = Instance.new("PitchShiftSoundEffect", Sound)
  12.     pitch.Octave = Pitches[math.random(1,#Pitches)]
  13. end
  14.  
  15. local function ConfigureSound(Sound:Sound)
  16.     Sound.SoundId = "rbxassetid://"..NewDeathSound
  17.     Sound.RollOffMaxDistance = 700
  18.     Sound.Volume = 1
  19. end
  20.  
  21. if RootPart then
  22.     local Found = RootPart:FindFirstChild("Died")
  23.     if Found then
  24.         ConfigureSound(Found)
  25.         AddPitchShift(Found)
  26.     end
  27. end
  28.  
  29. function updatePlayer(plr)
  30.     plr.CharacterAdded:Connect(function(char)
  31.         local RootPart = char:FindFirstChild("HumanoidRootPart")
  32.         if RootPart then
  33.             local Found = RootPart:FindFirstChild("Died")
  34.             if Found then
  35.                 ConfigureSound(Found)
  36.                 AddPitchShift(Found)
  37.             end
  38.         end
  39.     end)
  40.     if plr and plr.Character then
  41.         local RootPart = plr.Character:FindFirstChild("HumanoidRootPart")
  42.         if RootPart then
  43.             local Found = RootPart:FindFirstChild("Died")
  44.             if Found then
  45.                 ConfigureSound(Found)
  46.                 AddPitchShift(Found)
  47.             end
  48.         end
  49.     end
  50. end
  51.  
  52. local function e()
  53.     while true do
  54.         wait()
  55.         for _, newplr in pairs(game.Players:GetPlayers()) do
  56.             wait()
  57.             updatePlayer(newplr)
  58.             newplr.CharacterAdded:Connect(function(char)
  59.                 local RootPart = char:FindFirstChild("HumanoidRootPart")
  60.                 if RootPart then
  61.                     local Found = RootPart:FindFirstChild("Died")
  62.                     if Found then
  63.                         ConfigureSound(Found)
  64.                         AddPitchShift(Found)
  65.                     end
  66.                 end
  67.             end)
  68.         end
  69.  
  70.         game.Players.PlayerAdded:Connect(function(newplr)
  71.             updatePlayer(newplr)
  72.         end)
  73.     end
  74. end
  75.  
  76. coroutine.wrap(e)()
Tags: #Fun
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement