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

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

01local UserInputService = game:GetService("UserInputService")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local backwards_anim = ReplicatedStorage:WaitForChild("backwards_anim")
04local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
05 
06local function inputbegan(inputObject, gameProcessedEvent)
07 
08    if gameProcessedEvent then return end
09 
10        if inputObject.UserInputType == Enum.UserInputType.Keyboard then
11            local KeyCode = inputObject.KeyCode
12 
13            if KeyCode == Enum.KeyCode.S then
14                humanoid:GetState(state)
15 
View all 27 lines...

Any help would be greatly appreciated!

1
Which line is the error on? oilkas 364 — 5y
1
Try getting Humanoid in line 4 like this: local humanoid = script.Parent:WaitForChild("Humanoid") because the script is in startercharacterscripts and see if that helps?? oilkas 364 — 5y
0
Will try that when I get back onto my computer later (currently on mobile). DemonHunterz6 35 — 5y
0
Sorry, didn't work. The same error still showed up. DemonHunterz6 35 — 5y

Answer this question