Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

W001: unkown global "UserInputType"?

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.