I want to make a script that when you press x, your character automatically runs in the direction its facing. I've tried all sorts of things and I can't figure it out. Does anyone know how to do this? (sorry for my bad grammar, I couldn't think of another way to explain it)
✓ ANSWER ACCEPTED
how to move character with a script?
2 answers
✓ Accepted answer
here:
--first the when x is pressed then
local h = game.Players.LocalPlayer.Character.Humanoid
if h~=nil then
h.Torso.CFrame = CFrame.new(0,0,0) -- Place A Position Here, You can put (players Position) + (100,0,0)
local plr = game.Players.LocalPlayer
game:GetService("UserInputService").InputBegan:Connect(function(key,isTyping)
if isTyping == false and key.KeyCode == Enum.KeyCode.X then
local movePosition = plr.Character.HumanoidRootPart.CFrame:ToWorldSpace(CFrame.new(0,0,-100).p
plr.Character:WaitForChild("Humanoid"):MoveTo(movePosition)
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It worked after I played around with it. A lot.
:)