NPC pathfinding breaks when player jumps

I came out to devforum to ask for help regarding NPC pathfinding breaks when a player jumps. I tried fixing the pathing system for the NPC but it still comes with the same result. I have linked some photos of the console log and the parts of the script that is not working.
kOzglK1XfT

	local function fn()

		local target,path = getTarget()
		if (target and _G.TagGameData.Participants[target.Name] and (not usingElevator)) then

			local hum,rt = target:FindFirstChildOfClass('Humanoid'),target:FindFirstChild('HumanoidRootPart')
			if ((hum and rt) and hum.Health > 0) then

				local connect
				connect = hum.Running:Connect(function(speed)
					human.WalkSpeed = walkSpeed+math.abs(walkSpeed-speed)
				end)

				--Determine whether to take the elevator or directly pathfind to them

				if (path.Status == Enum.PathStatus.Success) then --Path successfully created, just directly pathfind to the target
					pathfindModule:pathfindTo(root.Position, rt.Position, path);
			(Line 156) ->	elseif (_G.TagGameData.Config.dummy.elevatorConfig.enable == true) then

					--Get the nearest floor to both the dummy's position and the target's position
					if (not elevator) then

					--	--If the set elevator from the tag game loader's config does not exist, get the nearest available elevator in game and utilize that
					local dist = math.huge;
						for i,v in pairs(elevators) do
							if ((v:FindFirstChild('Legacy') and (v.Legacy.Move_Value.Value == 0 or ((v.Legacy.Floor.Value >= tonumber(v.Name:sub(7)) and v.Legacy.Move_Value.Value == -1) or v.Legacy.Floor.Value <= tonumber(v.Name:sub(7)) and v.Legacy.Move_Value.Value == 1)))) then
								if ((v.Car.Platform.Position-root.Position).Magnitude <= dist) then
									dist = (v.Car.Platform.Position-root.Position).Magnitude;
									elevator = v;
								end
						end
					end
			end

Reply if you need any other code for this.

It looks like your code fails when it tries to index the _G.TagGameData.Config.dummy.elevatorConfig.enable value. Pathfinding fails, so your “elseif” is called. Is there some circumstance in your game that sets that value, maybe that isn’t getting set before the player jumps?

There is a setting on that, and it’s currently “false”.

Do you believe it could be the setting itself?

In your console, type print(_G.TagGameData.Config.dummy.elevatorConfig.enable) and see what comes out. It’s getting a nil value when it tries to access it.

lGAnnhUZCR

It looks like the code doesn’t see the elevatorConfig table. Are you confident that it’s set before your pathfinding code runs?

I can show you the elevatorconfig table.

task.wait() --Prevents the dummy from loading incorrectly
	local this = source.Parent
	local human = this:WaitForChild('Humanoid')
	local root = this:WaitForChild('HumanoidRootPart')

	local backup = this:Clone()

	local isDead = false;

	local forceField = Instance.new('ForceField', this)
	game:GetService('Debris'):AddItem(forceField, math.random(3, 15))

	local service = function(s) return game:GetService(s) end

	local pathfindingService = service('PathfindingService')
	local collectionService = service('CollectionService')
	local physicsService = service('PhysicsService')

	local elevator = _G.TagGameData.Config.dummy and _G.TagGameData.Config.dummy.elevatorConfig and _G.TagGameData.Config.dummy.elevatorConfig.elevatorToTake or nil;

	if (not _G.TagGameData.Config.dummy) then
		_G.TagGameData.Config.dummy = {

			['walkSpeed'] = 45;
			['ignoreObjects'] = {};
			['elevatorConfig'] = {
				['elevatorToTake'] = nil; --If enabled, the dummy will attempt to take the nearest elevator;
				['elevatorsNotToTake'] = {}; --A blacklist for which elevators the dummy should not take
				['enable'] = false; --Whether to enable or disable this feature
			};

		};
	end

Before the line with the error, add a simple “print(_G)” (or print(_G.TagGameData) if you have a bunch of other stuff in there) to spit out the information. That should help us track it down.

JR22nJ5cnL
DkIMwSWXq2

These above were print(_G.TagGameData)

343XiEitI0

IM2ZYaXaW9

This was print(_G)

Are you in Studio where you can look at that in the output window? I believe tables will print fully there, whereas in the game console they just spit out an object reference.

Oh okay, cause that was just in-game servers, not Roblox Studio Play Test. I will try it in the studio and give you screenshots from the output. Also, I have to have 2 people trigger the Dummy API system.

Yea, I can’t get it to trigger the table print, because I need 2 people to trigger it.

You can test in Studio using two players in the Test tab, under Clients and Servers. There’s a drop down to select a number of players and a server type. It’ll open a window for each player and one for the server.

Aw yes, I forgot about that. Let me do that, one moment.

That is all I got out of that.