"attempt to call a userdata value"?
Asked by
5 years ago Edited 5 years ago
What we've got here is a small local-script located in StarterCharacterScripts that (I don't know if giving a breakdown of it is redundant, I'm new to this website) listens to player input concerning the keycode "S", which is my choice for if the player moves backwards.
The error is whenever I run the game and try moving my character backwards with the "S" key, the following message appears in the output each input. The error source is this local script, on line 5.
22:00:04.265 - attempt to call a userdata value
Here is the code:
01 | local UserInputService = game:GetService( "UserInputService" ) |
02 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
03 | local backwards_anim = ReplicatedStorage:WaitForChild( "backwards_anim" ) |
04 | local humanoid = game.Players.LocalPlayer.Character:WaitForChild( "Humanoid" ) |
06 | local function inputbegan(inputObject, gameProcessedEvent) |
08 | if gameProcessedEvent then return end |
10 | if inputObject.UserInputType = = Enum.UserInputType.Keyboard then |
11 | local KeyCode = inputObject.KeyCode |
13 | if KeyCode = = Enum.KeyCode.S then |
14 | humanoid:GetState(state) |
16 | if state = = Enum.HumanoidStateType.Running or Enum.HumanoidStateType.RunningNoPhysics then |
17 | backwards_anim:FireServer(humanoid) |
18 | print ( "Animation request!" ) |
27 | UserInputService.InputBegan:Connect(inputbegan) |
Any help would be greatly appreciated!