How can you make a Tool equip Animation?

Hi!
I have made a sword with a Tool, and i want to make a equip Animation, but i cant seem to get it to work…
here is the script and how it looks:
image
The LocalScript:

local tool = script.Parent
local anim = script:WaitForChild("Animation")
local c = game.Players.LocalPlayer.Character
local Anims = {
	"rbxassetid://9496813134",-- Equip
	
}
local function equip()
	anim.AnimationId = Anims[1]
local load = c.Humanoid:LoadAnimation(anim):Play()
end

tool.Equipped:Connect(equip)

Any help would be appreciated!

6 Likes

Try edit your Animation Priority so it doesn’t affect other animations. I assume the problem is that your animation is glitching within other animations running in the character. It is suggested to make yours Action.

1 Like

game hasn’t loaded yet, the character is nil, add repeat wait() until game:IsLoaded() on the top or game.Players.LocalPlayer.CharacterAdded:Wait(), whatever works best
plus animation must have animation priority set to movement or action just in case

You should load the animation into Humanoid:WaitForChild("Animator").

Also remove the “,” inside your table as you only have one thing inside of it.

yes i have alredy set my AnimationPriority to Action and done the

game.Players.LocalPlayer.CharacterAdded:Wait()

but still it doesnt want to work…

leave that aside for now, IamProtectingPeople should have the answer above you

you shouldnt load same animations repeatedly i recommended storing them instead on a variable or even inside a table you cant exceeded more than 256 tracks

an organized one

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Tool = script.Parent
local Animation = script.Animation

local Humanoid = Character:WaitForChild("Humanoid")

local AnimationIds = {
	"http://www.roblox.com/asset/?id=656118852"
}

local Tracks = {}

for Index, AnimationId in pairs(AnimationIds) do -- converting all the animation ids to loaded animations or track
	Animation.AnimationId = AnimationId
	Tracks[Index] = Humanoid:LoadAnimation(Animation)
	local CurrentTrack = Tracks[Index]
	CurrentTrack.Priority = Enum.AnimationPriority.Action -- Highest Priority
end

local function OnEquipped() -- plays only the first track arranged base on the animation ids
	Tracks[1]:Play()
end

local function OnUnequipped() -- on this function it will stop all the stored tracks when the tool is unequipped as the event triggers it
	for _, Track in pairs(Tracks) do
		if Track.IsPlaying then
			Track:Stop()
		end
	end
end

Tool.Equipped:Connect(OnEquipped)
Tool.Unequipped:Connect(OnUnequipped)
6 Likes