Client PathFinding issues

Hey Developers. I am Kind of new to PathFinding. I have used it like 3 times before, using the help of Outside sources & Videos. Now I need to use PathFinding on the client, as the Agent moves at different times for everyone. Whether this is an issue or not, Idk, I just in the past have only used it on the server.

2 Issues Arise from this:

  1. The Agent is stuck standing still until I get close to it. I want it to start moving as soon as I call the function to allow it to start moving.
    Screenshot (2322)

  2. I have Objects that Move in real time. Ex. An Object that once a player gets close, It moves. My agent get stuck on this sometimes like this, and I am wondering if there is a way to make it Compute a path in real timeafter each waypoint, without being too wasteful? If that makes sense. Object Movements are always the same and predictable. Agent Movements might not always be

Screenshot (2323)

This is my code

local function MonsterRun()
	
	
	
	task.wait(1)
	local Path = pathFindingService:CreatePath()
	local ListOfColor = {BrickColor.new("Really red"), BrickColor.new("Neon orange"), BrickColor.new("Yellow flip/flop"), BrickColor.new("Lime green"), BrickColor.new("Royal blue"), BrickColor.new("Royal purple")}
	local Number = 0
	local PickColor = 0
	repeat
		Number += 1
		PickColor += 1
		if PickColor >= #ListOfColor then
			PickColor = 1
		end
		
		Path:ComputeAsync(Monster.Head.Position, game.Workspace.AgentPath:FindFirstChild("Path"..Number).Position)
		local Waypoints = Path:GetWaypoints()
		
		for i, eachPoint in ipairs(Waypoints) do 
			Monster.Humanoid:MoveTo(eachPoint.Position)
			Monster.Humanoid.MoveToFinished:Wait(2)
			
			local part = Instance.new("Part")
			part.Parent = game.Workspace.AgentWaypoints
			part.Shape = "Ball"
			part.Material = Enum.Material.Neon
			part.Size = Vector3.new(0.6,0.6,0.6)
			part.Anchored = true
			part.CanCollide = false
			part.Position = eachPoint.Position
			
			part.BrickColor = ListOfColor[PickColor]
		end
		Monster.Humanoid:MoveTo(game.Workspace.AgentPath:FindFirstChild("Path"..Number).Position)
		Monster.Humanoid.MoveToFinished:Wait(2)
		
	until Number >= 12
	
end

--Lines not related to this exist here...

coroutine.wrap(MonsterRun)()

Any and All help is much appreciated!

I did change My script. I am still confused at why It gets stuck at spawn until I get closer. But after that, It doesn’t get stuck on Moving Objects too much. Just don’t understand why I have to get close for it to start

local function MonsterRun()
	
	
	print("Starting")
	task.wait(1)
	local Path = pathFindingService:CreatePath()
	local ListOfColor = {BrickColor.new("Really red"), BrickColor.new("Neon orange"), BrickColor.new("Yellow flip/flop"), BrickColor.new("Lime green"), BrickColor.new("Royal blue"), BrickColor.new("Royal purple")}
	local Number = 0
	local PickColor = 0
	repeat
		Number += 1
		PickColor += 1
		if PickColor >= #ListOfColor then
			PickColor = 1
		end
		
		Path:ComputeAsync(Monster.Head.Position, game.Workspace.AgentPath:FindFirstChild("Path"..Number).Position)
		local Waypoints = Path:GetWaypoints()
		print("Running")
		for i, eachPoint in ipairs(Waypoints) do 
			if eachPoint.Action == Enum.PathWaypointAction.Jump then
				Monster.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			end
			print(eachPoint.Position)
			Monster.Humanoid:MoveTo(eachPoint.Position)
			repeat 
				local distance = (eachPoint.Position - Monster.PrimaryPart.Position).magnitude
				wait() until distance <= 5
			
			local part = Instance.new("Part")
			part.Parent = game.Workspace.AgentWaypoints
			part.Shape = "Ball"
			part.Material = Enum.Material.Neon
			part.Size = Vector3.new(0.6,0.6,0.6)
			part.Anchored = true
			part.CanCollide = false
			part.Position = eachPoint.Position
			
			part.BrickColor = ListOfColor[PickColor]
		end
		Monster.Humanoid:MoveTo(game.Workspace.AgentPath:FindFirstChild("Path"..Number).Position)
		repeat 
			local distance = (game.Workspace.AgentPath:FindFirstChild("Path"..Number).Position - Monster.PrimaryPart.Position).magnitude
				task.wait() until distance <= 5
		
	until Number >= 12
	
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.