Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I force a player to move forward?

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.

1 comment

0

I want it to move forward forever

1 answer

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.

3 comments

0

bad suggestion

0

Well it is a suggestion, I didn't say it was perfect

0

Why are you answering a question that you have posted a mod claim against??

This discussion is preserved as it was. New answers, comments, and votes are closed.