I have made an animation but I don't know how to make it play when a key is pressed this is just for one of my games. The game is non Filtering Enabled so don't worry about remotes and stuff.
http://wiki.roblox.com/index.php?title=API:Class/Humanoid/LoadAnimation Try this. When a key is pressed, load the animation into the humanoid and play it.
You can use the UserInputService to detect a key pressed then load the animation like this, it also doesn't matter if its Filtering Enabled or not.
local p = game.Players.LocalPlayer local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=id goes here" local UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(input, gameProcessedEvent) local KeyCode = input.KeyCode if not gameProcessedEvent then if KeyCode == Enum.KeyCode.E then -- Change E to any key you want local animTrack = p.Character.Humanoid:LoadAnimation(animation) animTrack:Play() end end end)
Marked as Duplicate by Goulstem
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?