I wanna make a hacking computer games.And i want the player look at computer. These is my coding, and thanks for helping!
local player = game.Players.LocalPlayer
local character = player.Character.Humanoid
local Computer = game.Workspace.Computer.Keyboard.Body
local radius = 10
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.E then
if player:DistanceFromCharacter(Computer.Position) <= radius then
character:MoveTo(workspace.Computer.Hack.Position)
--Rotate myself please C:
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

5 comments
This is worked! thanks for your answer!!
But i have a question, why when this code started, i'll jump?
It's just related to physics and CFrame and whatnot. If your game uses R6 and not R15, you could use the character's Torso instead for this which seems to be a little smoother.
I do use R15, and i press E(the keycode), i'll jump. Maybe is height difference?
I found it! i can use LowerTorso to take this problem! anyways. thank you!