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)