Hey developers I have a question about a key down animation script. The animation is a front flip. I am trying to make it so when a player presses “r” on his or her keyboard it does the animation. I looked it up on You Tube and the script that is given in the video doesn’t work. I don’t know if it would effect anything that the game is saved to my desktop. Let me know a new way or how to fix it thanks! From John…
Animation link: Front Flip - Roblox
1 Like
Replace line 7 with this
anim.AnimationId = "rbxassetid://2074693420"
3 Likes
You can also try other methods to achieve such goals by using services such as UserInputService and ContextActionService.
ContextActionService
This service is slightly faster since it will fire only when the button you want is pressed, unlike UserInputService where it will check every input until it finds the input from the key that’s desired.
local CAS = game:GetService("ContextActionService")
local deb = false
local function Binding(name, state, obj)
if not deb then
if state == Enum.UserInputState.Begin then
deb = true
--Action
deb = false
end
end
end
CAS:BindAction("AnimationPlay (change this to anything)", Binding, false, Enum.KeyCode.R)
UserInputService
local UIS = game:GetService("UserInputService")
local function InputBegan(input, processed)
if input == Enum.UserInputType.Keyboard then
local key = input.KeyCode
if key == "R" then
--Action
end
end
end
UIS.InputBegan:Connect(InputBegan)
4 Likes