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

Why doesn't my part follow the path?

I have been trying to write a script on giving a part some AI. Then I wrote this code and the part didn't follow the path.

--Script Made By: Troloolooolooll
	
--Declaring Variables
local startPos = script.Parent.Position
local endPos = game.Workspace.End.Position
local box = script.Parent
local path = game:GetService("PathfindingService"):ComputeRawPathAsync(startPos, endPos, 200)
points = path:GetPointCoordinates()

for i = 1, #points do
	box.Velocity = points[i]
end

1 comment

0

Your script changes box's Velocity to a coordinate point on line 11. You might want to change that.

1 answer

First of all, you set the Velocity property for some reason. You should be setting either the CFrame or Position properties. Secondly, you need to add a wait in your numerical for loop on line 10.

local startPos = script.Parent.Position
local endPos = game.Workspace.End.Position
local box = script.Parent
local path = game:GetService("PathfindingService"):ComputeRawPathAsync(startPos, endPos, 200)
points = path:GetPointCoordinates()

for i = 1, #points do
	box.CFrame = CFrame.new(points[i])
	wait(.1)
end

1 comment

0

Thanks!

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