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

How do I make tool animations? I've tried many things that just don't work

I'm pretty new to scripting and i'm trying to make a tron disk that when you click it plays an animation and attacks. The problem is, I don't know where to start. I've tried pasting and modifying other scripts into it but they never work. Even things like this /

-- Waits for the child of the specified parent local function WaitForChild(parent, childName) while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end

local Tool = script.Parent

local Animations = {} local MyHumanoid local MyCharacter

local function PlayAnimation(animationName) if Animations[animationName] then Animations[animationName]:Play() end end

local function StopAnimation(animationName) if Animations[animationName] then Animations[animationName]:Stop() end end

function OnEquipped(mouse) MyCharacter = Tool.Parent MyHumanoid = WaitForChild(MyCharacter, 'Humanoid') if MyHumanoid then Animations['EquipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'EquipAnim5')) Animations['IdleAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'IdleAnim3')) Animations['OverheadAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'OverheadAnim2')) Animations['SlashAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'SlashAnim2')) Animations['ThrustAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'ThrustAnim2')) Animations['UnequipAnim'] = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'UnequipAnim2')) end PlayAnimation('EquipAnim') PlayAnimation('IdleAnim') end

function OnUnequipped() for animName, _ in pairs(Animations) do StopAnimation(animName) end end

Tool.Equipped:connect(OnEquipped) Tool.Unequipped:connect(OnUnequipped)

WaitForChild(Tool, 'PlaySlash').Changed:connect( function (value) --if value then PlayAnimation('SlashAnim') --else -- StopAnimation('SlashAnim') --end end)

WaitForChild(Tool, 'PlayThrust').Changed:connect( function (value) --if value then PlayAnimation('ThrustAnim') --else -- StopAnimation('ThrustAnim') --end end)

WaitForChild(Tool, 'PlayOverhead').Changed:connect( function (value) --if value then PlayAnimation('OverheadAnim') --else -- StopAnimation('OverheadAnim') --end end)

If someone could help me figure out scripting this sort of thing it would help out alot! Thanks!

6 comments

0

Please enclose your code in the blocks created when you press the Lua logo above the question edit box.

0

I know how to make the animations but now how to put them into tools is what i'm saying

0

The humanoid plays the animation, you can google 'humanoid' and 'animation' and it should bring you directly to it.

0

Ugh it didn't work. Here's a video I made with the problem: https://www.youtube.com/watch?v=-Z2C5xqcr0g

0

Script an animation that shows the player throwing the disk for the arm that's holding the disk. From there, just remove the tool from the player's character and put it in a safe place. Then just duplicate the parts and make it fly.

1 answer

What I do is position the tool correctly in the player's hand, then weld it. Then I play the game, and take a copy of my character. I stop the game, and paste my character into the workspace. From there you can animate the rig with the tool attached to the hand. Then set the animation to 'action' priority. Also, make sure that you lock all the other parts that aren't moving so the action plays smoothly with default player movements. Then after that export it. Then when the tool event is fired (click, button press, whatever), you play the animation on the player's humanoid.

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