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

the error is ''Position is not a valid member of Model'', when i go check it it goes into line 15?

local Molly = script.Parent
local humanoid = Molly.Humanoid

local PathfinderServise = game:GetService("PathfindingService")

local function getPath(destination)
	local pathParams = {
		['AgentHeight'] = 6,
		['AgentRadius'] = 2,
		['AgentCanJump'] = false
		
	}
	local path = PathfinderServise:CreatePath(pathParams)
	
	path:ComputeAsync(Molly.HumanoidRootPart.Position, destination.Position)
	
	return path	
end

local function walkTo(destination)
	local path = getPath(destination)
	
	for index, waypoint in pairs(path:GetWaypoints()) do
	    humanoid:MoveTo(waypoint.Position)
	    humanoid.MoveToFinished:Wait()
	end
end

local function patrol()
	local waypoints = workspace:GetChildren()
	local randomNum = math.random(1, #waypoints)
	walkTo(waypoints[randomNum])
end

while wait(2) do
	patrol()	
end




3 answers

You can't use Position at a model you have to use :MoveTo()

Position isnt a property of a model. Since there is multiple parts in a model so you would have to use :MoveTo()

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