I am trying to make a NPC ordering system like the one seen in many games, such as Bloxburg. The problem that I am experiencing is the fact that the rigs do not move up if one is removed.
This is what I got so far, and the problem is seen in this video below;
local pointTable = {workspace.DestinationPart1, workspace.DestinationPart3, workspace.DestinationPart5}
local rigTableA = {}
local rigTableB = {}
local rigTableC = {}
local tickStarted
function checkTimer(rigTable, destinationPart, lastTime)
if rigTable[1] then
if not tickStarted then
last = tick()
tickStarted = true
end
if tick() - lastTime >= 5 and rigTable[1] ~= nil then
rigTable[1].Humanoid:MoveTo(workspace.LeavingShop.Position)
rigTable[1]:Destroy()
table.remove(rigTable, 1)
newRig(rigTable, destinationPart)
tickStarted = false
last = tick()
end
end
end
function newRig(rigTable, DESTINATION_POINT)
for index, rigs in pairs(rigTable) do
local TARGET = DESTINATION_POINT.CFrame * Vector3.new(0, 0, 4 * index)
rigs.Humanoid:MoveTo(TARGET)
end
end
game:GetService("RunService").Heartbeat:Connect(function()
checkTimer(rigTableA, workspace.DestinationPart2, last)
end)
function Aftermath(DestinationPoint, rigTable, rigModel, humanoid)
local targetPos = DestinationPoint.CFrame * Vector3.new(0,0,4 * #rigTable)
humanoid:MoveTo(targetPos)
humanoid.MoveToFinished:Wait()
table.insert(rigTable, rigModel)
end
while true do
wait(1)
local destination = pointTable[math.random(1,#pointTable)]
local pickedPoint = workspace.DestinationPart1
local rigModel = game.ReplicatedStorage.Others.rigmodel:Clone()
local humanoid = rigModel.Humanoid
rigModel.Parent = workspace
humanoid:MoveTo(pickedPoint.Position)
if pickedPoint == workspace.DestinationPart1 then
humanoid:MoveTo(workspace.FlatPoint1.Position)
humanoid.MoveToFinished:Wait()
Aftermath(workspace.DestinationPart2, rigTableA, rigModel, humanoid)
if rigModel == rigTableA[1] then
last = tick()
tickStarted = true
end
end
If anyone could help it would be greatly appreciated. This isn’t the entire script as the rest of it doesn’t have anything to do with my problem, but if I left something out, let me know.