NPCs disappearing

[CLOSED]
Couldn’t find it so I just rewrote all the NPC scripts, but it has a different mechanic.

So I’m working on a game for fun, and I scripted a certain part of the script which is supposed to send cusomers(NPCs) into a lines where they get served coffee, but with the script that has the NPC at the front of the line pay, leave, and move all the NPCs a spot forward in line it randomly has the NPC turn invisible for like a few seconds then walk off towards the exit of the shop.

Script:

local Line = script.Parent.Parent.Parent.Parent.Name

workspace:FindFirstChild("Lines"):FindFirstChild(Line):FindFirstChild("P12").ChildAdded:Connect(function(child)
	
	local Human = child:FindFirstChild("Humanoid")
	script.Parent:FindFirstChild("LoadingBar"):TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Linear", 3)
	wait(3.5)
	script.Parent:FindFirstChild("LoadingBar"):TweenSize(UDim2.new(0, 0,1, 0), "Out", "Quart", 1)
	wait(1)
	child.Parent = workspace
	Human:MoveTo(workspace:FindFirstChild("Exits"):FindFirstChild(Line):FindFirstChild("P1").Position)
	
	for i,v in pairs(workspace:FindFirstChild("Lines"):FindFirstChild(Line):GetChildren()) do
		
		if v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC") and v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("OnTheMove").Value == false and v.Parent:FindFirstChild("P".. i).Name ~= "P1" and v.Parent:FindFirstChild("P".. i).Name ~= "P12" then
			
			v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("CurrentPos").Value = v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("CurrentPos").Value + 1
			v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("Humanoid"):MoveTo(v.Parent:FindFirstChild("P".. v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("CurrentPos").Value).Position)
			v.Parent:FindFirstChild("P".. i):FindFirstChild("NPC"):FindFirstChild("Humanoid").MoveToFinished:Wait()
			
		end
		
	end
	
end)

My PC is trash and this isn’t really something you can take pictures of so you can join the game to see the glitch in action.

I can see that the NPCs that disappear do not reappear.
Is that the problem you are asking about?

Yes I have rewrote the script, but instead of disappearing then reappearing they just disappear.

I saw that the NPC’s were running into the wall.
Perhaps setting the target location just short of the wall may help.

1 Like