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)