Please be advised that this is literally a 15 minute throw-together-script; I do plan to advance it at a later date.
The way this script works is by: Spawning Enemies / Hostiles / ETC. ServerSide in accordance to the Player(s) distance from the ‘Spawners’.
local Players = game:GetService("Players")
local SpawnPoints = game:GetService("Workspace")["SpawnPoints"]
local Points = {}
for _,i in pairs (SpawnPoints:GetDescendants()) do
if i:IsA("BasePart") and i.Name == "Point" then
table.insert(Points, i)
end
end
spawn(function()
while true do wait(.15)
for _,i in pairs (Players:GetPlayers()) do
if i.Character ~= nil then
for _,p in pairs (Points) do
if (i.Character["HumanoidRootPart"].Position - p.Position).Magnitude < 15 then
isSpawn(i, p)
else
end
end
end
end
end
end)
function isSpawn(i, p)
local z = p:GetChildren()
if #z > 0 then
print("Found!")
repeat wait()
if p:FindFirstChild("Bandit") ~= nil then
if (i.Character["HumanoidRootPart"].Position - p["Bandit"]["HumanoidRootPart"].Position).Magnitude > 50 then
p["Bandit"]:Destroy()
end
end
until p:FindFirstChild("Bandit") == nil
return
else
local NPC = script["Bandit"]:Clone()
NPC.Parent = p
NPC:MoveTo(p.Position + Vector3.new(0, 3, 0))
NPC["isFollow"].Disabled = false
return
end
end