I am trying to spawn maps into workspace(one at a time) in a loop for when players join. Then they teleport to it. It works, though it is only supposed to be one map. After they spawn in, another map starts loading in. Then the players teleport to that map. I have 2 maps in ServerStorage. FE is off.
Server Script is in ServerScriptService
maps = game.ServerStorage:GetChildren()
while wait(.5) do
if game.Players.NumPlayers >= 2 then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA('Hint') then
v:Destroy()
end
end
ranmap = math.random(1, #maps)
wait(1)
chosen = maps[ranmap]
chosenclone = chosen:Clone()
chosenclone.Parent = game.Workspace
if chosenclone.Parent == game.Workspace then
game.StarterGui.ScreenGui.Frame.Visible = true
game.StarterGui.ScreenGui.Frame.Map.Visible = true
game.StarterGui.ScreenGui.Frame.Madeby.Visible = true
game.StarterGui.ScreenGui.Frame.MapName.Visible = true
end
wait(5)
spawn = chosenclone.SpawnPoint
wait(5)
local player = game.Players.LocalPlayer
for i,v in pairs(game.Players:GetPlayers()) do
name = v.Name
check = v.Character
if check then
checkHumanoid = check:FindFirstChild("Humanoid")
if checkHumanoid then
check:MoveTo(spawn.Position)
end
end
end
else
if not(game.Workspace:findFirstChild("Hint")) then -- If a hint is not a child of the workspace
h = Instance.new("Hint", game.Workspace)
h.Text = "You need more than 1 player to play."
end
end
end

1 comment
I kept the whole script but removed the stuff you removed and put it the playeradded and mapinstanited and stuff like that, but then the hint that I put up if less than two people are in it will show a hint saying you need more than two players, even though I put two players in it stayed up.