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

How can I force a player to move forward? [closed]

Asked by 5 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

So basically I want to force a player to move in the direction their HumanoidRootPart is facing.

I tried doing a few things and every time it would go a random direction or just stop working at one point.

I tried using the lookVector of the HumanoidRootPart and it didn't work.

0
I want it to move forward forever RequiredModule 38 — 5y

Closed as Not Constructive by SerpentineKing and EpicMetatableMoment

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?

1 answer

Log in to vote
0
Answered by 5 years ago

You can force the character to move using the :MoveTo() function of Humanoids. If you place a part in front of the player, you can force them to continuously move by welding it (the part will be at a fixed offset) and setting the player to move to the part continuously.

Example Script

game:GetService("Players").PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        local Root = Character:WaitForChild("HumanoidRootPart")

        local part = Instance.new("Part")
        part.Name = "FollowMe"
        part.Anchored = false
        part.CanCollide = false
        part.Transparency = 1
        part.Parent = Character

        local weld = Instance.new("Weld")
        weld.Parent = part
        weld.Part1 = part
        weld.Part0 = Root
        weld.C0 = CFrame.new(0, 0, -10)

        repeat
            Humanoid:MoveTo(part.Position)
            wait()
        until nil
    end)
end)

This however doesn't prevent the player from unbinding the movement themselves, but the loop will prevent them from effectively stopping walking.

0
bad suggestion User#24403 69 — 5y
0
Well it is a suggestion, I didn't say it was perfect SerpentineKing 3885 — 5y
0
Why are you answering a question that you have posted a mod claim against?? User#5423 17 — 5y
Ad