Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my sword equip animation working?

my code:

local Tool = script.Parent
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character
if not Character or not Character.Parent then
	Character = Player.CharacterAdded:Wait()
end
local Humanoid = Character:WaitForChild('Humanoid')
local Animator = Humanoid:WaitForChild('Animator')

local EquipAnimation = Tool.Animations.Equip

local EquipAnimationTrack = Humanoid:LoadAnimation(EquipAnimation)
EquipAnimationTrack.Priority = Enum.AnimationPriority.Action
EquipAnimationTrack.Looped = false

Tool.Equipped:Connect(function()
	EquipAnimationTrack:Play()
end)

Tool.Unequipped:Connect(function()
	EquipAnimationTrack:Stop()
end)


it works in the animation editor but not when i test it. Can anybody help?

I have two keyframes if that helps. I also have a Motor6D attached to the hand.

3 comments

0

My theory is that the animation was created without the tool. I'm not the best at animating so it's just a guess. I recommend looking up a tutorial

0

I did use the tool during animation. It may be because I motor6ded it to the hand.

0

Could possibly be the fact you're trying to change the looped setting - last time I checked you couldn't do that via script, remove that and see what happens. Not the greatest animator but have animated tools before, code checks out besides that one thing so have a go.

2 answers

Here are a few troubleshooting tips.

. Did you put a valid AnimationID (that you uploaded, or group uploaded) in the Animations.Equip?

. Is this script a Script? If not. Put it as a Localscript as you are trying to get localplayer.

. Check in output in View > Output.

Why I am putting this? It worked perfectly in game and it should with you as well. Have fun!

2 comments

0

@Lakodex yea ive done all of that and it doesnt work

0

whats da Moderation claim for?

I found out it was because I used motor6ds! Thank you for your help!

2 comments

0

No problem! I will be locking this thread.

0

you dont have to lock it always

This discussion is preserved as it was. New answers, comments, and votes are closed.