Does anybody know how to make a tool with a custom idle and walking/running animation when equipped?
localScript inside tool:
01 | local tool = script.Parent -- The tool position |
02 | local player = game.Players.LocalPlayer |
03 | local Equipped = false -- The Bool that will be used later |
04 | local humanoid = player.Character:WaitForChild( "Humanoid" ) or player.Character.Humanoid -- The Humanoid |
05 | local Idle = script.Parent:FindFirstChild( 'Idle' ) or script.Parent.Idle -- Your Animation, be sure to put the ID |
06 | local run = script.Parent:FindFirstChild( "Run" ) |
07 | local LoadAnim |
08 |
09 | tool.Equipped:Connect( function () |
10 | if not Equipped and Idle and LoadAnim = = nil then |
11 | Equipped = true |
12 | LoadAnim = humanoid:LoadAnimation(Idle) |
13 | LoadAnim:Play() |
14 | end |
15 | end ) |