I am having trouble finding a spot to place a animation ID. When i place it any where the gun either fires one round and frezzes, or the animation ID that is place does nothing. The animation is going to be character movement. How would I tell the script to play animation when "R" is pressed and when gun is firing play recoil animation. Note this is not a request I just need a VALID answer.
✓ ANSWER ACCEPTED
How would i go about adding a animation ID to a gun script?
1 answer
✓ Accepted answer
This requires you to use the UserInputService.
Also, to use an animation, you'll have to create it yourself, as ROBLOX blocks access to other people's animations for whatever reason.
Here's a small bit of code to help you get started.
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=Your ID here"
local animTrack = nil
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
animTrack = player.Humanoid:LoadAnimation(animation)
print("R was pressed") --You'll want to put your code here
animTrack:Play()
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
THANK YOU SO MUCH! I really appreat this, if i had more rep points i would up vote you. This its splended !
Ay, no problem, Jeter! :)