You can put it right before you choose a random map, im not sure why just getting a random map isnt working for you so possibly shuffling it beforehand could work
local Maps = game.ServerStorage.Maps:GetChildren()
local numMaps = #Maps
print(Maps)
for i = 1, numMaps do
local randomIndex = math.random(i, numMaps)
Maps[i], Maps[randomIndex] = Maps[randomIndex], Maps[i]
end
print(Maps)
local InGame = game.ReplicatedStorage.InGame
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local Maps = game.ServerStorage.Maps:GetChildren()
local ChosenMap = Maps[math.random(1, #Maps)]
local ChoosenSpawn = ChosenMap.SpawnLocation
--- Teleport ---
local Maps = game.ServerStorage.Maps:GetChildren()
local numMaps = #Maps
print(Maps)
for i = 1, numMaps do
local randomIndex = math.random(i, numMaps)
Maps[i], Maps[randomIndex] = Maps[randomIndex], Maps[i]
end
print(Maps)
InGame.Changed:Connect(function()
if InGame.Value == true then
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = ChosenMap.SpawnLocation.CFrame
ChosenMap:Clone().Parent = workspace
end
else
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
workspace:FindFirstChild(ChosenMap.Name):Destroy()
end
end
end)
--- Intermission and game Timer ---
local function roundTimer()
while wait() do
for i = 10, 1, -1 do
InGame.Value = false
wait(1)
Status.Value = "Game starts in:"..i
end
for i = 10, 1, -1 do
InGame.Value = true
wait(1)
Status.Value = "Time left:"..i
end
end
end
spawn(roundTimer)
local InGame = game.ReplicatedStorage.InGame
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local Maps = game.ServerStorage.Maps:GetChildren()
local numMaps = #Maps
for i = 1, numMaps do
local randomIndex = math.random(i, numMaps)
Maps[i], Maps[randomIndex] = Maps[randomIndex], Maps[i]
end
local ChosenMap = Maps[math.random(1, #Maps)]
local ChoosenSpawn = ChosenMap.SpawnLocation
InGame.Changed:Connect(function()
if InGame.Value == true then
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = ChosenMap.SpawnLocation.CFrame
ChosenMap:Clone().Parent = workspace
end
else
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
workspace:FindFirstChild(ChosenMap.Name):Destroy()
end
end
end)
--- Intermission and game Timer ---
local function roundTimer()
while wait() do
for i = 10, 1, -1 do
InGame.Value = false
wait(1)
Status.Value = "Game starts in:"..i
end
for i = 10, 1, -1 do
InGame.Value = true
wait(1)
Status.Value = "Time left:"..i
end
end
end
spawn(roundTimer)
Yeah but the problem is this is the only script he has provided us and it looks like it just instantly starts a round there is no loop anywhere to be found in his code so this is the only explanation that i could think of to make it possibly get a new map each time this code is ran
edit: @MrOnlyKemal waiit i think your right i didnt see his map code beforeā¦ he has to assign the map to a new variable and get another random map
Shuffling DOES NOT do anything, itās just extra unneccesary code. If you want to make it random everytime the server starts, make a random map chooser, not shuffler
In some cases shuffling does actually work very well, but in this case your right it wont do anything because he isnāt assigning a new map when the round ends and a new one starts, I guess I just glossed over this fact
local InGame = game.ReplicatedStorage.InGame
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.Lobby.SpawnLocation
local Maps = game.ServerStorage.Maps:GetChildren()
local ChosenMap = nil
local ChoosenSpawn = nil
local function SetRandomMap()
ChosenMap = Maps[math.random(1, #Maps)]
ChoosenSpawn = ChosenMap.SpawnLocation
end
--- Teleport ---
InGame.Changed:Connect(function()
if InGame.Value == true then
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = ChoosenSpawn.CFrame
ChosenMap:Clone().Parent = workspace
end
else
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
local character = player.Character
character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
if ChosenMap then
ChosenMap:Destroy()
end
end
end
end)
--- Intermission and game Timer ---
local function roundTimer()
while wait() do
for i = 10, 1, -1 do
InGame.Value = false
wait(1)
Status.Value = "Game starts in:"..i
end
SetRandomMap()
for i = 10, 1, -1 do
InGame.Value = true
wait(1)
Status.Value = "Time left:"..i
end
end
end
spawn(roundTimer)