Why does my animation not work when the player dies?

  1. What do you want to achieve? Keep it simple and clear!.
    Well the script is based on making a dash, it works correctly when you start playing but if you die the animations disappear and I don’t know why.

  2. What is the issue? Include screenshots / videos if possible!
    image

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked for information and the only thing I saw was to do a loop repeat but it does not work either

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local Debounce = true
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:wait()

local humanoid = Character:WaitForChild("Humanoid")
--04828543601
--5539989502

	
local anim1= script.Animation1
local Anim1 = humanoid:LoadAnimation(anim1)

local anim2= script.Animation2
local Anim2 = humanoid:LoadAnimation(anim2)

local anim3= script.Animation3
local Anim3 = humanoid:LoadAnimation(anim3)

local anim4= script.Animation4
local Anim4 = humanoid:LoadAnimation(anim4)

local Sound = script:WaitForChild("Haoshoku Sound")

KeysDown={}
EE = script.SF.Value
local EiEi = 1
UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.LeftShift and plr.Character.Humanoid.Health > 0 then
		if EiEi == 1 then
			EE = true
			EiEi = 2
			print(1)
		elseif EiEi == 2 then
			EE = false
			print(2)
			EiEi = 1
		end
	end
end)

UIS.InputBegan:Connect(function(Input,Dash)
	if Dash then return end
	if Input.KeyCode == Enum.KeyCode.Q and Debounce == true then
		Debounce = false
		if KeysDown.W and EE == true then
		Anim1:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
		local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
		BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
		Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.A and EE == true then
			Anim2:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.RightVector * -100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.D and EE == true then
			Anim3:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.RightVector * 100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.S and EE == true then
			Anim4:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * -100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		end
		-----------------------------------------------------------------------
		if KeysDown.W and EE == false then
			Anim1:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.A and EE == false then
			Anim1:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(-5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.D and EE == false then
			Anim1:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(5,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		elseif KeysDown.S and EE == false then
			Anim1:Play()
			local sol = game.ReplicatedStorage.DashEffect:Clone()
			sol.Parent = workspace
			sol.Anchored = true
			sol.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5) * CFrame.fromEulerAnglesXYZ(50000,0,50000)
			local BV = Instance.new("BodyVelocity", plr.Character.HumanoidRootPart)
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
			Sound:Play()
			for i = 1,5 do
				wait(0.001)
				sol.Size = sol.Size + Vector3.new(1,1,1)
			end
			BV:Destroy()
			wait(0.2)
			sol:Destroy()
		end
		wait(0.2)
		Debounce = true
	else
		KeysDown[Input.KeyCode.Name]=true
	end
		
end)
	UIS.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		KeysDown[input.KeyCode.Name] = nil

	end
	
	end)

Animations are humanoid specific. You need to reload all animations every time you get a new humanoid, point to the new model in all references. I do this with “CharacterAdded”

Idk but that not works, another solution?

Idk where put that, can you help me I am new in code.

Hey, I know is late but you can try to set “BreaksJointOnDeath” to false, that property is on the Humanoid of the Character.