Animation not playing. Debugging works and no errors

Hello. I am making a fighting game and I am currently stuck on a problem. The problem is that my sword animation wont run even if I dont get any errors. The debugging/printing works but nothing happeneds. The code is in a localscript which is inside the handle of my sword tool. This is the code:


-- DEBOUNCE & INSTANCE

local tool = script.Parent.Parent

local swordDebounce = false

-- PLAYER

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:wait()

local Humanoid = char:WaitForChild("Humanoid")

local swordSlash = Humanoid:LoadAnimation(player.PlayerGui.Animations["Sword Slash"])

local rightarm = char["Right Arm"]

local handle6d = Instance.new("Motor6D", rightarm)

handle6d.Name = "Handle"

-- MAIN

tool.Equipped:Connect(function()

handle6d.Part0 = rightarm

handle6d.Part1 = script.Parent

end)

tool.Unequipped:Connect(function()

handle6d.Part0 = nil

handle6d.Part1 = nil

end)

tool.Activated:Connect(function()

swordDebounce = true

swordSlash.Priority = Enum.AnimationPriority.Action

print("Animation should play")

swordSlash:Play()

wait(swordSlash.Length + 1.5)

swordDebounce = false

end)

And as you can see in the following picture, it prints:
image

2 Likes

try reimporting the animation into roblox studio animation editor (default), and then before you export it again, find animation priority and make sure it’s on action.

Did that and the problem remains the same.

-- DEBOUNCE & INSTANCE
local tool = script.Parent.Parent
local swordDebounce = false

-- PLAYER
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local char = player.Character or player.CharacterAdded:wait()
local rightarm = char:WaitForChild("Right Arm")
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local swordSlash = animator:LoadAnimation(player:WaitForChild("PlayerGui"):WaitForChild("Animations"):WaitForChild("Sword Slash"))
local handle6d = Instance.new("Motor6D")
handle6d.Parnet = rightarm
handle6d.Name = "Handle"

-- MAIN
tool.Equipped:Connect(function()
	handle6d.Part0 = rightarm
	handle6d.Part1 = script.Parent
end)

tool.Unequipped:Connect(function()
	handle6d.Part0 = nil
	handle6d.Part1 = nil
end)

tool.Activated:Connect(function()
	swordDebounce = true
	swordSlash.Priority = Enum.AnimationPriority.Action
	print("Animation should play")
	swordSlash:Play()
	task.wait(swordSlash.Length + 1.5)
	swordDebounce = false
end)

would you mind explain what you did right here ? i have the same problem but didnt understand the fix

4 Likes

yeah what did you do to solve it

did u find a fix ? i stopped working on my game, because of that stupid glitch…

i can’t either, i wish i could get it cuz i need to animate my npcs so it’s more detailed

1 Like

DUDE, i just founded the solution, at least for me, i was playing my gun animation on a Local Script instead of a Script, and since my gun is not parented to my Character, it doesn’t work. what i’ll do is Make it so when i try to animate the gun, i fire that information to the server and the server plays the animation. Check it out to see if that isn’t your case aswell.

1 Like