As an example, the one used in Darkness 2. When you are at a certain distance from the door, if you press a certain key on your keyboard, it will open(If pressed, again it closes, but I can do that part.) How do I go about making a door like this? All help appreciated, Thank You. ~ Xduel
COMMUNITY QUESTION
How does one create a door using .KeyDown?
2 answers
Use magnitude to see how far a player is from a certain object, like so
if (workspace.Player1.Torso.Position - workspace.Part.Position).magnitude > 20 then
--then open door
end
that will check if the player is 20 studs away from the part named Part in workspace and then do the following code
ScriptingHelpers is not a request site but here is the basics of the code that will detect when the player presses e and then prints that the player has.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if Key == "e" then
print("User pressed e")
-- enter code here
end
end)
If you need more help here's the wiki page on taking keyboard input: http://wiki.roblox.com/index.php?title=Taking_keyboard_input
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Yeah, that is the easy part, but how will you know when it's close to a door?
I consider the keyboard input taking the more difficult part, the answer below talks about magnitude.