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?
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
It looks like you're using a LocalScript, based on the fact that you're getting LocalPlayer. ServerStorage can only be accessed by Normal Scripts located inside the Workspace or ServerScriptService. I hope this helps. :^)