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

How i put equip animation on a tool?

I have my custom animation but, i can't run it. I tried so many scripts but I do not see results, my goal is that when I click on the box where the tool is shown, the animation runs and it continue with the idle animation.

Edit 1: sorry for my bad english, i am from the moon.

4 comments

0

Guys, i dont think hes actually from the moon.

0

no, he is, from Moon, South Dakota

0

yes and im from mars

0

are you bruno mars

2 answers

you could do this

local animplay -- makes it nil and u can call it in more functions
tool.Equipped:Connect(function()
	animplay = humanoid:LoadAnimation(animation)
	animplay:Play() -- idle animations should be looped
end)
tool.UnEquipped:Connect(function()
	if animplay ~= nil then -- if its not blank or nil
		animplay:Stop()
	end
end)

pretty self explanatory. you should make sure the animation is looped and set to one of the higher priorities. NOTE: you should really define animation and humanoid; this isn't a complete script just a demonstration

Ok, so first, you need to try to find a way to get the player, and if this is a normal tool in the starter pack or a tool that will get cloned into the player's backpack sometime soon, then the variable

local player = script.Parent.Parent.Parent

would work.

And now we need to get our player's character

local player = script.Parent.Parent.Parent
local character = player.Character or player.CharacterAdded:Wait()

and now we need to get our tool, and the animationObject

local player = script.Parent.Parent.Parent
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local animation = pathToAnimation --Animation
local animationTrack --We'll give this a value later

And you need to be fimiliar with the Equipped event.

local player = script.Parent.Parent.Parent --Gets the player if this is a regular tool in starterpack
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local animation = pathToAnimation --Animation
local animationTrack --We'll give this a value later

tool.Equipped:Connect(function()
	--Empty
end)

So now, we need to go to the Humanoid and load the animation with Humanoid:LoadAnimation.

And your final product should look like this:

local player = script.Parent.Parent.Parent --Gets the player if this is a regular tool in starterpack
local character = player.Character or player.CharacterAdded:Wait()
local tool = script.Parent
local animation = pathToAnimation --Animation
local animationTrack --We'll give this a value later

tool.Equipped:Connect(function()
	animationTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
	animationTrack:Play()
end)

1 comment

0

And on a side note, make sure the animation is looped, and the priority for the animation is either Action or Movement

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