After player death, can not load animations

Self explanatory, I made a demon flip and demon step script, but when the player dies, the animations are unloadable. Here’s the script that handles the animation, and the local script that fires it.
SERVER::: DEMON FLIP

	local function playAnimationFromServer(character, animation)
		local Character = playerWhoFired.Character or playerWhoFired.CharacterAdded:Wait()
		local Humanoid = Character:FindFirstChildOfClass("Humanoid") or playerWhoFired.Character:WaitForChild("Humanoid")
		if Humanoid then
			local animation = script.Animation
			local animator = Humanoid:FindFirstChildOfClass("Animator") or Humanoid:WaitForChild("Animator")
			if animator then
				local animationTrack = animator:LoadAnimation(animation)
				animationTrack:Play()
				animationTrack:AdjustSpeed(1.5)
				local sound = Instance.new("Sound", playerWhoFired)
				sound.SoundId = "rbxassetid://5355789788"
				sound:Play()
				setParticles()
				animationTrack:GetMarkerReachedSignal("Attack"):Connect(function()
					canAttack = true 
					print("hi")
					wait(0.2)
					canAttack = false
					animationTrack.Stopped:wait()
					stopParticles()
					Weld:Destroy()
					part:Destroy()
					sound.Stopped:Wait()
					sound:Destroy()
				end)
			end
		end
	end

SERVER::: DEMON STEP

	local function playAnimationFromServer(character, animation)
		local Character = playerWhoFired.Character or playerWhoFired.CharacterAdded:Wait()
		local Humanoid = Character:FindFirstChildOfClass("Humanoid") or playerWhoFired.Character:WaitForChild("Humanoid")
	if Humanoid then
		local sound = Instance.new("Sound", playerWhoFired)
			sound.SoundId = "rbxassetid://4008161835"
			local animation = script.Step
			local animator = Humanoid:FindFirstChildOfClass("Animator") or Humanoid:WaitForChild("Animator")
			if animator then
				local animationTrack = animator:LoadAnimation(animation)
				animationTrack.Looped = true
			animationTrack:Play()
			setParticles()
				sound:Play()
				wait(0.6)
				animationTrack:Stop()
				animationTrack.Looped = false
			stopParticles()
			sound:Destroy()

		end
	end
	end

LOCAL::: DEMON STEP

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid") or character:FindFirstChild("Humanoid")
local HRP = character:WaitForChild("HumanoidRootPart")
local mouse = player:GetMouse()
local Cooldown = Instance.new("BoolValue", player)
local BV3
local Remote = game.ReplicatedStorage.Remotes.DemonStep
local canMove = false
local speed = 0.25
local function thread1()
	if canMove == true then
		repeat
			BV3.MaxForce = Vector3.new(1,1,1) * math.huge
			BV3.Velocity = character.HumanoidRootPart.CFrame.LookVector * 32
			wait()  
			game:GetService("RunService").Heartbeat:Wait()
		until canMove == false
	end
end
mouse.Button1Down:Connect(function()
	if character:FindFirstChild("DemonStep") and Cooldown.Value == false then
		BV3 = Instance.new("BodyVelocity", character.HumanoidRootPart)
		Cooldown.Value = true
		canMove = true
		Humanoid.WalkSpeed = 0
		spawn(thread1)
		Remote:FireServer()
		wait(0.6)
		canMove = false
		Humanoid.WalkSpeed = 16
		BV3:Destroy()
		BV3 = nil
	end
end)

Cooldown.Changed:Connect(function()
	if Cooldown.Value == true then
		wait(0.8)
		Cooldown.Value = false
	end
end)
Humanoid.Died:Connect(function()
	local fliptodestroy = character:FindFirstChild("DemonFlip") or game.Players.LocalPlayer.Backpack.DemonFlip
	fliptodestroy:Destroy()
	local steptodestroy = character:FindFirstChild("DemonStep") or game.Players.LocalPlayer.Backpack.DemonStep
	steptodestroy:Destroy()
end)

DEMON FLIP::: LOCAL

local Remotes = game.ReplicatedStorage.Remotes
local M1Event = Remotes.M1
local M2Event = Remotes.M2
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local character = Player.Character or Player.CharacterAdded:Wait()
local Cooldown = Instance.new("BoolValue", game.Players.LocalPlayer)
Cooldown.Value = false
local Humanoid = character:WaitForChild("Humanoid") or character:FindFirstChildOfClass("Humanoid")
local animator = Humanoid:FindFirstChildOfClass("Animator") or Humanoid:WaitForChild("Animator")
local Mouse = Player:GetMouse()
local m1 = Instance.new("Animation")
local Debounce = false
local BV 
local BV2 
local DebounceTimer = 6
m1.AnimationId = "rbxassetid://5945839988"
local m2 = Instance.new("Animation")
m2.AnimationId = "rbxassetid://5949219966"
local canMove
local model = character.HumanoidRootPart
local speed = 0.25
local function thread1()
	if canMove == true then
		repeat
			BV2.MaxForce = Vector3.new(1,1,1) * math.huge
			BV2.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 16
			wait()  
			game:GetService("RunService").Heartbeat:Wait()
		until canMove == false
	end
end
local function thread()
	if canMove == true then
		repeat
			BV.MaxForce = Vector3.new(1,1,1) * math.huge
			BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 13
			wait()
			game:GetService("RunService").Heartbeat:Wait()
		until canMove == false
	end
end
local tool = script.Parent.Parent.DemonFlip
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
	if character:FindFirstChild("DemonFlip") and Cooldown.Value == false and Humanoid.WalkSpeed > 0 and script.Parent.Parent.DemonFlip.Equipped then
		Cooldown.Value = true
		BV = Instance.new("BodyVelocity", character.HumanoidRootPart)
			Humanoid.WalkSpeed = 0
				M1Event:FireServer()
		canMove = true
spawn(thread)		
		wait(0.5)
		Humanoid.WalkSpeed = 16
				canMove = false
		BV:Destroy()
		BV = nil
	end
		end)


	
mouse.Button2Down:Connect(function()
		if character:FindFirstChild("DemonFlip") and Cooldown.Value == false and Humanoid.WalkSpeed > 0 and script.Parent.Parent.DemonFlip.Equipped then
		Cooldown.Value = true
		BV2 = Instance.new("BodyVelocity", character.HumanoidRootPart)
		M2Event:FireServer()
		Humanoid.WalkSpeed = 0
		canMove = true
		spawn(thread1)
		wait(1)
		canMove = false
		BV2:Destroy()
		BV2 = nil
		Humanoid.WalkSpeed = 16
		end
end)
Cooldown.Changed:Connect(function()
	if Cooldown.Value == true then
		wait(5)
		Cooldown.Value = false
	end
		end)
3 Likes

Would I have to redefine the player’s character on the server on death or something…

1 Like

Are you getting any errors? Or is it just not loading? Is it doing all the same things? Just not loading animations?

Not loading animations. No errors…

Hmm. Odd. I don’t think I’ve heard of animations not working after the character dies.

Only things I can really recommend is to print things, print the player, print the animation, print if it received it. Etc.

You have a few other things that aren’t in these scripts, so it’s hard to pin-point. So idk, unless someone else has some input.

If you can’t figure something out… you could somehow make a project with just all the same stuff, and send it to me, I could probably figure something out.

1 Like

I can’t figure it out, do you want me to send you a file of only those scripts?

If you can somehow have a file with everything that would make the demon flip work, that’d be preferable.

1 Like

flip models.rbxm (6.0 KB)
Put the tools in starterpack, put the scripts in ServerScriptService, put the Remotes folder in ReplicatedStorage, and change the animation ID’s of the animation instance inside the server scripts to your choose.
remotesfolder.rbxm (609 Bytes)

1 Like

Uh

List of errors that I got when player died, even though you said you got no errors…

I found that you don’t seem to use :FindFirstChild, and that ended up with a lot of errors with things indexing nil. So first off I’d say for future things, make sure something exists before doing anything to it.

So:
local rootpart = character:FindFirstChild(“HumanoidRootPart”)
if rootpart then
–Do stuff
end

Like this ^, if anything ever does index nil, it means you need something like this.

You also seemed to split up the client and server in weird ways. As well as you used the mouse to do M1, instead of just doing tool.Activated.

Also with stuff like this, you could’ve just made a ParticleEmitter with all these same variables and just plunked it somewhere like ReplicatedStorage. Then when you need it, just clone and put it where you want it.

If it was up to me, I’d probably re-write the entire thing, put one Script, not a localscript, in the tool. Then have everything handled in there. Instead of spreading everything out and making things more complicated.
I know there are better ways for optimization and what not, but whatevs.

I couldn’t get it working, unless someone else has some insight, so, sorry about that.
It was very jumbly, and I’m not used to working on client. Because it seems to do things like this. Compared to the server which can guarantee it finds what it needs to find.

I personally would recommend rewriting everything, but do more of it on server in a single script, and make use of the tool’s functions like tool.Activated.

I can tell you’re a new scripter, and I don’t want to discourage you, but pace yourself. If you don’t pace yourself, you’ll end up creating something big, finding lots of errors, and then not knowing what to do because you kinda dug yourself into a pit. Like this situation. I made this mistake as well.

Start small, look things up on devforums and the documentation, and good luck!

https://developer.roblox.com/en-us/learn-roblox/all-tutorials

1 Like