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

Keybind Animations don't work with UserInputService?

I've tried loads and loads of different methods to create key~bind animations, but none of them work. Even if I follow the tutorial It always shows the same error in output: Keycode Is Not A Valid Member Of InputObject... Can anyone help please? Here is the script if you need it:

local plr = game.Players.LocalPlayer
local char = plr.Character
local human = char:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://02762264324"

function onKeyPressed(inputObject, gameProcessEvent)
	if inputObject.Keycode == Enum.KeyCode.A then
		human:LoadAnimation(anim):Play()
		print("Animation is playing")
	end
end
uis.InputBegan:Connect(onKeyPressed)

I put the script in StarterGui, StarterPack... EVERYWHERE, is this a problem with my device or roblox studio?

2 comments

0

you might wanna load the animation above and set it as a variable, then play it

0

and also i would suggest to put the local script in starter character scripts.

1 answer

✓ Accepted answer

This is because roblox is sensitive when it comes to capitalization. Make sure to spell "Keycode" as: "KeyCode" make sure the "c" is capital.

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