#pathfind script does not work and i suck at scripting

1 messages · Page 1 of 1 (latest)

barren dagger
#

the pathfinding script i made (which kinda sucks) just wont work after i added the destDecider function but it worked beforehand, please help and explain what went wrong so i know not to make the same mistake

local PathServ = game:GetService("PathfindingService")
local RunServ = game:GetService("RunService")

local mainStageNode = game.Workspace.PathNodes.Bonnie:WaitForChild("BonMainStage")
local diningRoomNode = game.Workspace.PathNodes.Bonnie:WaitForChild("BonDiningRoom")

local bonnie = script.Parent
local humanoid = bonnie:WaitForChild("Humanoid")
local destinationNode = mainStageNode
local pathfindEnabled = true
local time = 1

local aggression = 20
local path = PathServ:CreatePath()

local success, errorMessage = pcall(function()
    local mainStagePath = path:ComputeAsync(bonnie.PrimaryPart.Position, destinationNode.Position)
end)

local function timeDecider()
    local timeNumber = math.random(30/aggression, 25-aggression)
    time = timeNumber
    print(time)
end

local function destDecider()
    if destinationNode == mainStageNode then
        destinationNode = diningRoomNode
    end
    print(destinationNode)
end

if success then
    timeDecider()
    destDecider()
    task.wait(time)
    for _,destinationNode in pairs(path:GetWaypoints()) do
        if pathfindEnabled == false then
            print("pathfindEnabled == false")
            break
        end
        print("success")
        humanoid:MoveTo(destinationNode.Position)
        humanoid.MoveToFinished:Wait()
    end
    RunServ.Heartbeat:Wait()
else
    warn(errorMessage)
end```
shrewd stream
#

why not just use forbidden?

barren dagger
shrewd stream
barren dagger
shrewd stream
#

it creates it for you

barren dagger
shrewd stream
#

I just heard that pathfinding is a headache and forbidden does it with like 1 line of code for you

#

I think there are more intresting things then pathfinding

barren dagger
#

@shrewd stream is there any tutorials for forbidden?

#

or should i just figure it out manually?

shrewd stream
#

The AI module has a documentation i think

barren dagger
shrewd stream
#

AI module

#

did y figure it out?

barren dagger
shrewd stream
#

how