Movement delay after using simple path( pathfinding service)

Hey, I am making a walking queue system and when I enable the movement it gets a slow delay. I disabled the players movement then let him walk to a point with simple path(a pathfinding module) and when he presses a butten it teleports him out and enables his movement again. But then he get’s a deley on the movement.
this is the code i used:

leave.OnServerEvent:Connect(function(player)
	local plaats = 0
	print(player.Name)
	local laasts = false
	local tags = script.Parent.Walkparts:GetChildren()
	local InverseIndex = #tags
	player.Character.HumanoidRootPart.CFrame = script.Parent.LeavePart.CFrame
	movement:FireClient(player, true)
	for i = InverseIndex, 1, -1 do
		local part = tags[i]
		if part.naam.Value ~= "None" then
			print(part.naam.Value)
			if part.naam.Value == player.Name then

				laasts = true
			end
			break
		end
	end
	for i = 1,#tags do
		local part = tags[i]
		plaats = plaats +1
		if part.naam.Value == player.Name then
			part.naam.Value = "None"
			print(plaats)
			break
		end
	end

	for i = 1,#tags do		
		local part = tags[i]
		if laasts == false then
			print("nietlaatst")
			if part.naam.Value ~= "None" and i ~=1 and part.naam.Value ~= player.Name then

				wait(1)
				move(game.Workspace:WaitForChild(part.naam.Value))
			end
		end

	end

end)

adding Wait, will make any action slower, as i noticed:

for i = 1,#tags do		
		local part = tags[i]
		if laasts == false then
			print("nietlaatst")
			if part.naam.Value ~= "None" and i ~=1 and part.naam.Value ~= player.Name then

				wait(1)
				move(game.Workspace:WaitForChild(part.naam.Value))
			end
		end
--remove this ''Wait(1)" and check if something will change

It doesn’t seem to fix it, this is the code I used for disabling the people movement.

What do you mean by delay? Is the movement stuttering? Or is it taking a bit before the character starts to walk again?

When I’m pressing space bar it has a delay to it, and the same with the movement, it has a late response, maybe like 0.5 s or so

Is it possible that Network Ownership isnt being set back to the player after walking? It is possible that the module sets network ownership already, if so then that would probably create lag if you’re not re-setting it back.

1 Like

That was the problem, I would never have found that.
Ty!

1 Like