Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Keybind Animations don't work with UserInputService?

Asked by 4 years ago

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:

01local plr = game.Players.LocalPlayer
02local char = plr.Character
03local human = char:WaitForChild("Humanoid")
04local uis = game:GetService("UserInputService")
05local anim = Instance.new("Animation")
06anim.AnimationId = "rbxassetid://02762264324"
07 
08function onKeyPressed(inputObject, gameProcessEvent)
09    if inputObject.Keycode == Enum.KeyCode.A then
10        human:LoadAnimation(anim):Play()
11        print("Animation is playing")
12    end
13end
14uis.InputBegan:Connect(onKeyPressed)

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

0
you might wanna load the animation above and set it as a variable, then play it Dexiber 272 — 4y
0
and also i would suggest to put the local script in starter character scripts. Dexiber 272 — 4y

1 answer

Log in to vote
0
Answered by
Dexiber 272 Moderation Voter
4 years ago

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

Ad

Answer this question