I am trying to make it so when 2 players are in the game, maps will be chosen out of the ServerStorage and cloned into Workspace and the players will go there. But when I test it, ServerStorage is empty, which causes it to not work. Why does it become empty? I also tried putting the maps in ReplicatedStorage and it didn't work, though they didn't remove. It is in a LocalScript, which was in ReplicatedFirst. I tried putting the code into a normal script inside workspace, it just displayed the gui. I tried using a game.Players.PlayerAddedfunction. It just displayed the gui. Nothing else. Sorry about the long question :/
maps = game.ServerStorage:GetChildren()
local player = game:GetService"Players".LocalPlayer
local guis = player:WaitForChild"PlayerGui"
while wait(.5) do
if game.Players.NumPlayers >= 2 then
guis.ScreenGui.Frame.Map.Visible = false
guis.ScreenGui.Frame.Madeby.Visible = false
wait(3)
ranmap = math.random(1, #maps)
guis.ScreenGui.Frame.Visible = true
guis.ScreenGui.Frame.Beingchosen.Visible = true
wait(1)
chosen = maps[ranmap]
chosenclone = chosen:Clone()
chosenclone.Parent = game.Workspace
guis.ScreenGui.Frame.Map.Visible = true
guis.ScreenGui.Frame.Madeby.Visible = true
guis.ScreenGui.Frame.Madeby.Text = "Map is " .. chosen.Name .. " By: Spoookd"
wait(5)
spawn = chosenclone.SpawnPoint
for i,v in pairs(game.Players:GetPlayers()) do
name = v.Name
check = game.Workspace:FindFirstChild(name)
if check then
checkHumanoid = check:FindFirstChild("Humanoid")
if checkHumanoid then
check:MoveTo(spawn.Position)
end
end
guis.ScreenGui.Frame.Visible = false
end
else
guis.ScreenGui.Frame.Visible = false--I moved this
h = Instance.new("Hint", game.Workspace)
h.Text = "You need more than 1 player to play."
end
end
