local enabled = true Player = script.Parent.Parent --Player:WaitForDataReady() mouse = Player:GetMouse() run = game:GetService("RunService") function onKeyDown(key) if not enabled then return end enabled = false key = key:lower() if key == "z" then local animation = Instance.new("Animation") animation.AnimationId = "b126ab943d35e9b7e3bb92379d9504d7" local animTrack = humanoid:LoadAnimation(animation) animTrack:Play() end end enabled = true mouse.KeyDown:connect(onKeyDown)
Im not sure if the animation is stopping it from working or if it is the OnKeyDown, please help.
To get your asset Id you need to Export the animation. Do this by going to the animation editor > (Make your animation) Click the + in th upper left hand corner > Click export. When it is finished uploading go to your inventory > Animations > (your animation) Now copy the numbers at the end of the link.
Put the numbers in the script like so:
local enabled = true Player = script.Parent.Parent --Player:WaitForDataReady() mouse = Player:GetMouse() run = game:GetService("RunService") function onKeyDown(key) if not enabled then return end enabled = false key = key:lower() if key == "z" then local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/asset/?id=218192180" --218192180 is an example. Replace it with your ID local animTrack = humanoid:LoadAnimation(animation) animTrack:Play() end end enabled = true mouse.KeyDown:connect(onKeyDown)