Before I start, I’m just gonna say I’m not asking for scripts. I’m just asking how I should make it, as the way I tried turned out to be a big mess.
Hello. I’m trying to make a minigames game, like Epic Minigames. With gamemodes, maps, etc. But I’m having trouble matching the gamemodes with the maps. Like I don’t want a sword fight gamemode with an obby map. How should I go about fixing this?
Here’s the code I have right now, just so you can get an idea of how I’m doing this:
local Maps = game.ServerStorage.Maps:GetChildren()
local Gamemodes = {"Sword Fight", "Juggernaut", "Obby", "4 Corners"}
local Status = game.ReplicatedStorage.Status
repeat Status.Value = "2 or more players required to start the game, "..#game.Players:GetPlayers() task.wait() until #game.Players:GetPlayers() >= 1
local gameTable = {}
local winner
function reward(player, amt)
player.leaderstats.Tokens.Value += amt
end
while true do --game loop
for i = 10,1,-1 do
Status.Value = "Intermission: "..i
task.wait(1)
end
task.wait(1)
Status.Value = "Choosing map and gamemode"
repeat
chosenMap = Maps[math.random(1,#Maps)]
chosenGamemode = Gamemodes[math.random(1,#Gamemodes)]
until chosenMap.Gamemode.Value == chosenGamemode
task.wait(math.random(1, 2.5))
Status.Value = "Loading "..chosenGamemode.." on "..chosenMap.Name
chosenMap.Parent = game.Workspace
task.wait(1)
Status.Value = "Teleporting players..."
task.wait(1)
for _,v in pairs(game.Players:GetPlayers()) do
v.Character:SetPrimaryPartCFrame(chosenMap.Teleports[math.random(1,#chosenMap.Teleports:GetChildren())].CFrame + Vector3.new(0,2,0))
end
if chosenGamemode == "Sword Fight" then
for _,v in pairs(game.Players:GetPlayers()) do
game.ServerStorage.Assets.Sword:Clone().Parent = v.Backpack
end
elseif chosenGamemode == "Juggernaut" then
local selected = game.Players[math.random(1,#game.Players:GetPlayers())]
print(selected)
selected.Character.Head.GUI.Holder.Title.Text = "Juggernaut"
end
for _,v in pairs(game.Players:GetPlayers()) do
table.insert(gameTable, v.Name)
end
spawn(function()
while true do
if #gameTable == 1 then
winner = game.Players:FindFirstChild(gameTable[1])
end
task.wait()
end
end)
for i = 25,1,-1 do
Status.Value = "In game: "..i
task.wait(1)
end
Status.Value = "Game over!"
for _,v in pairs(game.Players:GetPlayers()) do
v:LoadCharacter()
end
task.wait()
end