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 3 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:

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?

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

1 answer

Log in to vote
0
Answered by
Dexiber 272 Moderation Voter
3 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