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

how to move character with a script?

Asked by
ax_gold 360 Moderation Voter
7 years ago
Edited 7 years ago

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)

2 answers

Log in to vote
1
Answered by 7 years ago

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)
0
It worked after I played around with it. A lot. ax_gold 360 — 7y
0
:) fireburnpokemon 16 — 7y
Ad
Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
7 years ago
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)

Answer this question