So, i made my own custom PathFinding script… So what it does is that it should find the nearest player to it and chase them, yet it doesn’t work? i’ve tried reading doing everything to avoid posting and doing unnecessary actions/posts… but i really cant find a solution… anyways i have no idea on what is causing this bug, what so ever…
Script
local NearestTarget = FindPlayer()
local path = PathFindingService:CreatePath()
if NearestTarget then
path:ComputeAsync(ClanBossModel.HumanoidRootPart.Position, NearestTarget.HumanoidRootPart.Position)
print(NearestTarget.Name)
end
local Waypoints = path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
humanoid:WalkTo(waypoint.Position)
humanoid.MoveToFinished:Wait(2)
end
not the full script, tho… but it is where the PathFinding part is…
for some more info here is the screen shot of the bot, after joining the game and the screen shot of the output after joining the game…
Screenshots
If you think you know the solution please consider telling me down in the comments, Thanks!
Hey there!! i added some finishing touches to my script and some things didnt work… i think its the problem with the script itself… can you please take a look at it? oh and it keeps giving me this error:
WalkTo is not a valid member of Humanoid
at this line:
humanoid:WalkTo(waypoint.Position)
this is the script:
local NearestTarget = FindPlayer()
local pathParams = {
AgentRadius = 4,
AgentHeight = 5,
AgentCanJump = false --default is true
}
local path = PathFindingService:CreatePath(pathParams)
if NearestTarget then
path:ComputeAsync(ClanBossModel.HumanoidRootPart.Position, Workspace.Union.Position)
print(NearestTarget.Name)
end
local Waypoints = path:GetWaypoints()
for i, waypoint in pairs(Waypoints) do
humanoid:WalkTo(waypoint.Position)
humanoid.MoveToFinished:Wait(2)
end
Note: it does print “WhatDid_HeDo” aka my username meaning that the print NearestTarget Works and that HumanoidRootPart isnt anchored