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

keyboard letter "E" to teleport?

i want to make a roblox teleporter which when the player walks up and it says "click E to teleport" and if you click E you teleport i just need to know what to add or change in my code thx

function onTouched(hit)  --i know i have to change this but what too--
  print("Teleport")
  local human = hit.Parent:findFirstChild("Torso")
  brick = script.Parent
  if (human ~=nil) then
    human.CFrame= CFrame.new(Vector3.new(-185.8, 357.3, -569.6))--location you want to telport to.--
   end
end

script.Parent.Touched:connect(onTouched) --i dont know about this one--

6 comments

0

Instead of human.CFrame= CFrame.new(Vector3.new(-185.8, 357.3, -569.6)) try human.CFrame= script.Parent.CFrame. Also, instead of if (human ~= nil) then, you can just do if human then.

0

Line 10 is the most important thing, oh and also, this script only works when someone touchs a block, what is your purpose about this, a GUI which says E or click E to teleport?

0

to change it so you click E to teleport

0

its not a request

0

Yes it is.

0

how

2 answers

✓ Accepted answer

Make sure this is a local script

function teleport()
    local char = game:GetService("Players").LocalPlayer.Character
    char.HumanoidRootPart.CFrame = CFrame.new(-185.8, 357.3, -569.6)
    
end

game:GetService("ContextActionService"):BindAction(
    "Teleport", 
    teleport, 
    false, 
    Enum.KeyCode.E
)

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