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)
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.