Ok, I think you got a bit mixed up with UIS.
Make sure you're using a localscript! Very important as UIS only runs on the client
The InputBegan event gives two parameters, the input and the game processed event, not the player. Just get the player through game.Players.LocalPlayer
UserInputType detects what type of input the player is using, such as keyboard, mouse, touchscreen, etc. To sense if the user is pressing a specific key, change the UserInputType you're checking for to keyboard, then add the following code inside:
1 | if input.KeyCode = = Enum.KeyCode.E then |
This should work:
01 | local UIS = game:GetService( "UserInputService" ) |
02 | local tool = script.Parent |
04 | local function OnInputBegan(input, GPE) |
05 | if input.UserInputType = = Enum.UserInputType.Keyboard then |
06 | if input.KeyCode = = Enum.KeyCode.E then |
07 | tool:Clone().Parent = player.Backpack |
08 | print ( "E was pressed" ) |
13 | UIS.InputBegan:Connect(OnInputBegan) |
Hopefully this helps