Enum.Keycode

Enum.Keycode is mostly used for detecting when a player presses a key on their keyboard. Here's an example:

(This is a client script that can be put in StarterGui or StarterPlayerScripts, your choice.)
local key = game:GetService("UserInputService")

local tool = Instance.new("Tool")

key.InputBegan:Connect(function(input)

      if input.Keycode == Enum.Keycode.E then

            tool.Name = "YourCustomName"

            tool.Parent = game.Players.LocalPlayer.Backpack

      end

end)

if tool.Parent == game.Players.LocalPlayer.Backpack then

      script:Destroy()

end

This will give a tool to a player when E is pressed. The script after it will prevent duplicate tools being given. You can retrieve the script after the player's death from another script.

Retrieve script on player's death:

(In the underlined area, write the parent of the script not both.)

local player = game.Players.LocalPlayer

local Char = player.Character or Player.CharacterAdded:Wait()
local humanoid = Char:WaitForChild("Humanoid")

if humanoid.Health == 0 then

      if player.Backpack:FindFirstChild("YourCustomName") then

            wait(Char.RespawnTime)

            local retrievescript = game.StarterGui/StarterPlayer.StarterPlayerScripts.LocalScript:Clone()

            retrievescript.Parent = player.Backpack

     end

end

 

Create Your Own Website With Webador