I created an animation (that is on the ROBLOX site now, I had to pay 30 R$) that I would like to play when a player presses the W or UP arrow key on the keyboard, but I do not know how to do this.
Any help?
Thank you!
I created an animation (that is on the ROBLOX site now, I had to pay 30 R$) that I would like to play when a player presses the W or UP arrow key on the keyboard, but I do not know how to do this.
Any help?
Thank you!
local animation = Instance.new("Animation")
animation.AnimationId = "animation ID" -- ex http.robloxblahblah
local animTrack = Humanoid:LoadAnimation(animation)
function onKeyDown(key)
key = key:lower()
if key == "w" then -- i dont know how to do it for the up key, sorry
animTrack:Play()
end
end
script.Parent.Parent:GetMouse().KeyDown:connect(onKeyDown)
make sure it is in a local script, in the player's backpack
you forgot to tell the game what "Humanoid" is.:local Humanoid = game.Players.LocalPlayer.Character.Humanoid
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Are you looking to trigger an animation if someone moves?(script.Parent.Parent.Character.HumanoidRootPart.Velocity is how fast the player is moving if the script is in the backpack.)