Hi,
I’m using pathfinding to make this girl walk to the player. All of the parts around her are not colliding, the players body and the girls body are not colliding and i have no idea what the problem is anymore. I set the agentHeight and agentRadius to 1, made jumping possible and debugged my entire script.
What could possibly be the problem?
function Stage3:InitPathfinding()
local GirlMagazine = game.Workspace:FindFirstChild("MagazineGirl")
local Humanoid = GirlMagazine:FindFirstChild("Humanoid")
local function checkMagnitude(obj1, obj2)
return (obj1.Position - obj2.Position).Magnitude
end
local function followPath(destination)
print('follow function called')
if mustFollow == true then
print('mustfollow = true')
destination = self.Player.Character or self.Player.CharacterAdded:Wait()
local pos = GirlMagazine.PrimaryPart.Position
local succes, err = pcall(function()
Path:ComputeAsync(pos, destination.PrimaryPart.Position)
print('computed a sync')
end)
if succes and Path.Status == Enum.PathStatus.Success then
print('was succesful')
waypoints = Path:GetWaypoints()
blockedConnection = Path.Blocked:Connect(function(blockedIndex)
if blockedIndex >= nextWaypointIndex then
blockedConnection:Disconnect()
followPath()
end
end)
if not reachedConnection then
reachedConnection = GirlMagazine.Humanoid.MoveToFinished:Connect(function(reached)
local obj1 = GirlMagazine.HumanoidRootPart
local obj2 = self.Player.Character.HumanoidRootPart or self.Player.CharacterAdded:Wait().HumanoidRootPart
if checkMagnitude(obj1, obj2) < 5 then
obj2.Parent.Humanoid.Health = 0
mustFollow = false
GirlMagazine.Parent = Assets.Models
GirlMagazine:SetPrimaryPartCFrame(workspace['Stage3'].girlSpawn.CFrame)
end
if reached and nextWaypointIndex < #waypoints then
nextWaypointIndex += 1
GirlMagazine.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
followPath()
else
followPath()
end
end)
end
nextWaypointIndex = 2
if waypoints[nextWaypointIndex] then
GirlMagazine.Humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
end
else
followPath()
end
end
end
followPath()
end