This script works fine, but I want it to cycle through each map, rather than just picking one immediately. I want the ChosenMinigame value to be changed to a random map before 'choosing' one.
local minigames = game.ServerStorage:GetChildren()
local GameTime = 15
--if game.Players.NumPlayers > 1 then
wait()
-----------------------------------Getting the minigames from ServerStorage
while true do
local random = math.random(1, #minigames)
local gameChosen = minigames[random]:Clone()
print("The game is: ", gameChosen)
gameChosen.Parent = game.Workspace
game.Workspace.Value.Value = gameChosen.Name
------------------------------------Checking for players with the same name
spawns = gameChosen:GetChildren()
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
if checkHumanoid.Health > 0 then
check:MoveTo(spawns[i].Position)
end
end
end
end
--Values for GUIs
for i = GameTime, 1, -1 do
game.Lighting.CountDownGui.Value = "Time left: " .. i
game.Lighting.ChosenMinigame.Value = "Minigame: " .. game.Workspace.Value.Value-- This holds the chosen minigame value
-- The GUIs text changes based on these values.
wait(1)
end
game.Lighting.CountDownGui.Value = "Game over!"
game.Lighting.ChosenMinigame.Value = "Intermission"
game.Workspace.Value.Value = "Intermission"
------------------------------------Giving players points
for y, x in pairs(game.Players:GetPlayers()) do
inGame = x:FindFirstChild("InGame")
if inGame then
x.leaderstats.Points.Value = x.leaderstats.Points.Value + 100
print(x.leaderstats.Points.Value)
print(x.Name .. " wins!")
else
print("NO INGAME VALUE")
end
end
------------------------------------
gameChosen:Destroy()
wait(10)
end
--else
print("MORE THAN ONE PLAYER NEEDED")
--end
