Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

keyboard letter "E" to teleport? [closed]

Asked by 5 years ago

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--
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. duje225_awesome 10 — 5y
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? AIphanium 124 — 5y
0
to change it so you click E to teleport snakieandy -1 — 5y
0
its not a request snakieandy -1 — 5y
View all comments (2 more)
0
Yes it is. User#19524 175 — 5y
0
how snakieandy -1 — 5y

Closed as Not Constructive by User#19524, brokenVectors, and Leamir

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 5 years ago

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
)
Ad
Log in to vote
-1
Answered by 5 years ago

https://wiki.roblox.com/index.php?title=API:Class/Mouse/KeyDown

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
if Mouse.KeyDown:connect(function(key)
    if key == "e" then
        --code
    end
end
0
KeyDown is deprecated. User#19524 175 — 5y