Key Press to Teleport

Where to put the code

Code

-- We must get the UserInputService before we can use it
local UserInputService = game:GetService("UserInputService")
 
-- A sample function providing one usage of InputBegan
local function onInputBegan(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.E then
        local player = game.Players.LocalPlayer
        player.Character.HumanoidRootPart.CFrame = CFrame.new(x, y, z)
    end
end
 
UserInputService.InputBegan:Connect(onInputBegan)