✓ Accepted answer
Hey! Sorry I answered a bit late but I have a thought that might be somewhat useful.
So basically, every set amount of time, a object (or npc in your case will move to a set location every time it gets told too, it also moves furthest away from the player(s) and doesn't move to the same space 2 times in a row.
SETUP: Figure it out I'm too lazy sorry i'm doing a skribbl.io tournament lol
Here:
local npcModel = game.Workspace.Crate1
local npcLocationFolder = game.Workspace.GameFolder.DepositFolder
local SET_TIME = 14
local npcLocations = crateLocationFolder:GetChildren()
local function moveNPCToPart(locationPart)
npcModel:SetPrimaryPartCFrame(locationPart.CFrame)
end
local function getTotalPlayerDistanceFromPart(locationPart)
local totalDistance = 0
local players = game.Players:GetPlayers()
for i = 1, #players do
local player = players[i]
local distance = player:DistanceFromCharacter(locationPart.Position)
totalDistance = totalDistance + distance
end
return totalDistance
end
local function changeNPCPosition()
local greatestDistance = 0
local locationPartPicked
for i = 1, #npcLocations do
local locationPart = npcLocations[i]
local distance = getTotalPlayerDistanceFromPart(locationPart)
if distance >= greatestDistance then
greatestDistance = distance
locationPartPicked = locationPart
end
end
end
moveNPCToPart(locationPartPicked)
end
while true do
wait(SET_TIME)
changeNPCPosition()
end
if it breaks just message me and i will see whats wrong
cya :D