Animations dont work after daeth

i have a walk anim script that doesent really work when the player dies the anim reset to the deafaullt one heres the script

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)

– Create Animation objects
local walkAnim = Instance.new(“Animation”)
walkAnim.AnimationId = “rbxassetid://108225171834776”

local idleAnim = Instance.new(“Animation”)
idleAnim.AnimationId = “rbxassetid://132866122719981”

– Load animations
local walkTrack = humanoid:LoadAnimation(walkAnim)
local idleTrack = humanoid:LoadAnimation(idleAnim)

– Start with idle animation playing
idleTrack:Play()

– Function to switch animations based on movement
local function onRunning(speed)
if speed > 0 then
if not walkTrack.IsPlaying then
idleTrack:Stop()
walkTrack:Play()
end
else
if not idleTrack.IsPlaying then
walkTrack:Stop()
idleTrack:Play()
end
end
end

– Connect running event
humanoid.Running:Connect(onRunning)

Move this script to StarterCharacterScripts!

The reason this is most likely happening is that this is only applied to the character once the player spawns in, and it isnt applied to any newly added characters!

By putting the script in StarterCharacterScripts it will load every time a new character is created, thus loading the new animations onto it!

If this doesnt work, any more details involving the issue would help!