How should I go about creating a minigames game?

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
2 Likes

Try using modulescripts instead - they can help you organize stuff.

Intermission > Require Modulescript from a random selection > return list of winners from Modulescript > do something for the winners

1 Like

Hey there! I have a tutorial series on how to make a game like epic minigames (a mini game game)! That might help you anyways here is the link!

2 Likes

If possible what you would want to do is create 1 Module that stores all the methods you will need and 1 Server that manages all the players and requires the Methods from the module form there, The script would provide Info that the Module would need to proceed.

CollectionService and attributes combined can be very powerful in this instance. You can assign a tag to maps using CollectionService. For example, any ‘combat’ map would have a MAP_COMBAT tag. Then, you can add attributes to specify some constraints. For example, how many players does this map support?

Once you have tagged each map and assigned attributes where necessary, you can use the CollectionService:GetTagged() method to return the maps suitable for the chosen game mode. The trick here is that maps that can be used in multiple game modes (e.g. a sword fighting game mode and a laser tag game mode) can have multiple tags assigned to them. That way they appear in multiple lists!

After CollectionService returns a list of tagged maps, you can then loop through them and filter out any other maps that are not suitable, such as maps that are too big, require an even number of players, etc. You would use the attributes you assigned earlier for this part.

Finally, you’ll be left with one list of maps suitable for the chosen mode!

I’ve never used CollectionService. Could you explain?

just put the maps in a folder and name them exactly like the gamemode name and you can do like
game.ReplicatedStorage.Maps[randomgamemode] – do it with roblox math.random(1,#Gamemodes)