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

W001: unkown global "UserInputType"?

Asked by 4 years ago

For some reason when I use my script. it says :W001: unkown global "UserInputType" can someone help? here's my script:

local UIS = game:GetService("UserInputService")
local Human = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local Part = game.Workspace.EPart
UIS.InputBegan:connect(function(input)
    if UserInputType == Enum.UserInputType.Keyboard then
    if input.KeyCode == Enum.KeyCode.E then
        if (Part.Position - Human.Position).magnitude < 20 then
            print("Your pressed E in a magnitude 20 of a part.. congrats?")
            end
        end
    end
end)

1 answer

Log in to vote
1
Answered by
Memotag 226 Moderation Voter
4 years ago
Edited 4 years ago

You are using UserInputType in the wrong context.

You will want to replace that line with:

if input.UserInputType == Enum.UserInputType.Keyboard then

instead.

On a side note, connect is deprecated so use Connect instead.

Ad

Answer this question