I am making a war game and I need to make animations so that each tool has special keys to create animations.
For example, you can press T to throw stars once you equip the tool "Ninja Stars."
I know about this (click to play anim):
Tool = script.Parent local player = game.Players.LocalPlayer repeat wait() until player.Character ~= nil local hum = player.Character:WaitForChild("Humanoid") local animation = Tool.ToolAnim local AnimTrack = hum:LoadAnimation(animation) Tool.Activated:connect(function(mouse) mouse.Button1Down(connect(function() AnimTrack:Play() end) Tool.Deselected:connect(function() AnimTrack:Stop() end)
But how do i put an key in it and play an animation so the player with the tool equipped plays it whenever he presses T?
Just change the function that does AnimTrack:Play() to one like this:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "t" then AnimTrack:Play() end end)