Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make an animation play on button hit?

In my game, players are supposed to have a custom animation to walk, but I don't know how to trigger the animation on key hit. (Like, the player presses "W" and the animation plays).

Thank you.

2 answers

You have to use the animation plugin to create a walking animation, then pay 30 robux to upload it for use. Then you right the script for the animation to play when the player presses "w"

You could use this script:

--Made by Tynexx

--Fixed by iDarrick





game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local ani = char:FindFirstChild("Animate")
if ani then
ani:Destroy()
local nani = game.Lighting.NewAnimation
if nani then
nani:Clone().Parent = char
end
end
end)
end)

Just go into studio, click tools, test, and play solo. Go to the model in workspace called "Player1". Copy the script "Animate". Go into the script and replace the id in "walk" with your animation's ID. Also, go into the StringValue "walk" and it's child animation "WalkAnim" And put the same ID you put in the Script there. Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.