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

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

Asked by 3 years ago
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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

Ad
Log in to vote
0
Answered by
I_Nev 200 Moderation Voter
3 years ago

Try using destination.PrimaryPart.Position

Log in to vote
0
Answered by 3 years ago

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

Answer this question