How to create a Line NPC?

hello all want to make Npc, Like in this picture


where if NPCs spawn, they will line up neatly.

Video NPC

I don’t know where to start, I’m just using this script so how do I get the NPCs to line up neatly?

what should I add to this script and how do I get started?
Script

local NPC = script.Parent
local RunsAim = NPC.Run
local IdleAim = NPC.idle
local RunsAims = NPC.Humanoid:LoadAnimation(RunsAim)
local idleAims = NPC.Humanoid:LoadAnimation(IdleAim)


while true do 
	wait(0.5)	
	NPC.Humanoid:MoveTo(script.Parent.Parent.Move1.Position)
	NPC.Humanoid.MoveToFinished:wait()
	RunsAims:Play()
	wait(2)
	RunsAims:Stop()
	NPC.Humanoid:MoveTo(script.Parent.Parent.Move2.Position)
	NPC.Humanoid.MoveToFinished:wait()
	wait(2)
	RunsAims:Play()
	NPC.Humanoid:MoveTo(script.Parent.Parent.Move3.Position)
	NPC.Humanoid.MoveToFinished:wait()
	RunsAims:Stop()
	wait(2)
	RunsAims:Stop()
	NPC.Humanoid:MoveTo(script.Parent.Parent.Move4.Position)
	NPC.Humanoid.MoveToFinished:wait()
	RunsAims:Play()
	wait(1)
	NPC.Humanoid:MoveTo(script.Parent.Parent.Move6.Position)
	idleAims:Play()
	RunsAims:Stop()
	wait(6)
	idleAims:Stop()
	RunsAims:Play()
	NPC.Humanoid:MoveTo(script.Parent.Parent.Exit.Position)
	wait(6)
end

When you spawn in an NPC make him move to the furthest spot in the queue. Whenever an NPC leaves the queue make all the other NPCs move to the next position. This event based approach should work just fine.

1 Like

Your way of doing is not bad too, you can play with some numbers to make it work, but there are several answers made for the same topic too, somewhat more professional ways, here are some of them:

Also use task.wait() instead of wait() if you just want to yield the thread for a specific period of time, it’s more accurate and efficient.

2 Likes

thank you very much your answer is very helpful to me

1 Like

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