local players = game.Players
local bases = workspace.Bases:GetChildren()
local assigned = {} -- track who owns which base
players.PlayerAdded:Connect(function(player)
-- Find an unassigned base
local baseToGive = nil
for _, base in ipairs(bases) do
if not assigned[base] then
baseToGive = base
assigned[base] = player
break
end
end
-- If no bases left, use default spawn
if not baseToGive then return end
-- When the player spawns, place them
player.CharacterAdded:Connect(function(char)
local hrp = char:WaitForChild("HumanoidRootPart")
local spawn = baseToGive:WaitForChild("SpawnPoint")
hrp.CFrame = spawn.CFrame + Vector3.new(0, 3, 0)
end)
end)