Making a minigame system

Hey there,
So I am trying to make a minigame game but I’m not sure how to create a system that will pick a mini game, I am familiar with pick maps just picking minigames and making them work I cannot do.
Any help would be massively appreciated.

2 Likes

Personally, and someone can correct me if this is bad practice, I simply put the script in the map itself and when the map is cloned to workspace the code runs. I think you can also have a function for each minigame and run it but for me it’s been easier to just let the maps handle their own games.

2 Likes

Heres a script that will pick a random Child Model from ServerStorage named “Maps” and put it in workspace.
Put a StringValue in the script named “ChosenMap” for it to work

(This script isnt made by me btw)

function chooseMap()
	local choices = {}
	for i = 1, #maps do
		if maps[i]:IsA("Model") then
			table.insert(choices, maps[i])
		end
	end
	local picked = math.random(1,#maps)
	chosenmap.Value = choices[picked].Name
end

function loadMap()
	local map = game.ServerStorage.Maps:FindFirstChild(chosenmap.Value):Clone()
	map.Parent = currentmap
end

function deleteMap()
	for i,v in pairs(currentmap:GetChildren()) do
		if v:IsA("Model") then
			v:Destroy()
		end
	end
end

while true do
    wait(5)
    chooseMap()
    loadMap()
    wait(1)
    teleportPlayers()
    wait(20)
    teleportBack()
    deleteMap()
end

The script is from this tutorial: How To Make A Random Map Picker, check it out… Might help you

3 Likes

I thought scripts don’t work when cloned?

They work for me, I don’t clone the script itself but the model that it’s in, although I suppose that’s the same thing. Since I clone from server storage I can just delete it and the script will be reset the next time I clone it.