Animation not playing and don't know how to make a different animation play on M2, Want it to only play on equipped

  1. I want to make Demon Flip like in Rogue Lineage, and I have the animations for it.
  2. The animation is not loading on activating the tool, and I don’t know how to make a different one play on m2…
  3. I tried this code, and nothing happens
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local Humanoid = character:WaitForChild("Humanoid")
local m1 = Instance.new("Animation")
m1.AnimationId = "rbxassetid://5945839988"
local track = Humanoid:LoadAnimation(m1)
local tool = script.Parent.Parent.DemonFlip
tool.Activated:Connect(function()
	track:Play()
end)

For M2.
Get the mouse on a localscript.

And then have on Button2Down, Fire a remote event to the script that does the animations or whatever.

And voila do the thing.

Also another handy link.

Thanks, but the animation is not playing on M1

Alright, so now it works.

local Player = game.Players.LocalPlayer
local character =Player.Character or Player.CharacterAdded:wait()
local Humanoid = character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local m1 = Instance.new("Animation")
local Debounce = false
local DebounceTimer = 10
m1.AnimationId = "rbxassetid://5945839988"
local m2 = Instance.new("Animation")
m2.AnimationId = "rbxassetid://5946655147"
local runtrack = Humanoid:LoadAnimation(m2)
local track = Humanoid:LoadAnimation(m1)
local tool = script.Parent.Parent.DemonFlip
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
	if script.Parent.Parent.DemonFlip.Equipped and Debounce == false and runtrack.IsPlaying == false then
		Debounce = true
	track:Play()
	end
end)
Mouse.Button2Down:Connect(function()
	if Debounce == false and script.Parent.Parent.DemonFlip.Equipped and track.IsPlaying == false and script.Parent.Parent.DemonFlip.Equipped == true then
		runtrack:Play()
	end
end)
wait(DebounceTimer)
Debounce = false

I want it to only play while equipped

For this I’d usually do;

local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
    if character:FindFirstChild("DemonFlip") then
        local track = Humanoid:LoadAnimation(m1)
        m1:Play()
    end
end)

mouse.Button2Down:Connect(function()
    --Do same thing in first function but with a different animation
end)

I don’t think tools have a function for Mouse2, so you have to make a function for it like this.