Hello, everyone! I have a problem where I desire to make a random minigame for the players every round. Ns can already make the minigames, but there is one problem I’m having. Ns trying to do the minigame there is no using recurring if statements.I used math.random() to create a arbitrarily number however writing:

if num == 1 then function() if num == 2 then function() if num == 3 climate function()Is also repetitive. How would ns go about making this in an efficient way? I’m sure that games with many minigames don’t usage 100 if statements, so who helping me would certainly be appreciated!

P.S: I had some concepts like placing all the maps right into a folder dubbed “Minigames” and also then placing scripts inside the maps that get permitted when their game is called. Instead of using if statements, I would certainly loop with the maps folder and also choose a random minigame. However, too many scripts is annoying to work-related with, so i’m trying to use attributes all in one script. As soon as again, say thanks to you!

Hey, ns am pretty certain there space some great online tutorials you can follow. Just shot not come copy and also paste make sure you understand and also learn the script before you usage it.

You are watching: How to make a minigame in roblox

If You have Multiple Maps then You can Do It choose This…

First develop A Folder called Map In Replicated Storage and also Place All her Maps In There.

2.Now create A manuscript In ServerScriptService and You have the right to Write Something like This

local MapsFolder = game:GetService("ReplicatedStorage"):WaitForChild("Map")local Maps = MapsFolder:GetChildren()local ChooseMap = Mapslocal Clone = ChooseMap:Clone()Clone.Parent = game.Workspace
i tried searching, yet none that them had actually a video game with an ext than 2 minigames, for this reason they just used if statements.

The thing about this manuscript is the it’s just choosing a map. Ns can currently choose a arbitrarily map and clone it, I simply don’t know exactly how to have a function run if that details map is chosen

RefinedDev (Refined) September 9, 2020, 11:37am #6

What function You desire To Do?Like A Timer system Or Somthing?

dodle120 (muffins) September 9, 2020, 11:40am #7

LIke rules. For example, one video game can it is in a murder mystery where one player is handed a gun and another video game can be musical chairs. I simply don’t know how to operation the murder secret script if the murder secret map is chosen.

See more: 15 Best Things To Do In Rockville Md, The 10 Best Fun Activities & Games In Rockville

I thought of permitting scripts that are youngsters of the map, however I don’t desire too countless scripts

RefinedDev (Refined) September 9, 2020, 12:27pm #9

You deserve to Make Module Scripts for Your features Then require Them when The Map You want Is Chosen.

CowboySticky (Sticky) September 9, 2020, 12:16pm #10

Here friend go, this could assist you:

game.Players.PlayerAdded:Connect(function() local an outcome = math.random(1,3)local FinalNumber = 0FinalNumber = Resultif FinalNumber == 1 thenendif FinalNumber == 2 thenendif FinalNumber == 3 thenendend)
That’s an additional thought i had but I wasn’t sure of just how I would do it. I deserve to make the functions in the module script, but how would certainly I call it in the server script if a details map is chosen. For example:

regional minigames = require(ModuleScript) Minigames<#maps>
You deserve to See even if it is The Map liked Name Is The surname Of her Map, If Yes then Require.Likeif Clone.Name == “Map” thenrequire(Clone.ModuleScript)

So I know what you’re saying, however wouldn’t this need a module manuscript for every minigame? would that be it s okay for the video game or destroy the performance?Also, wouldn’t this bring up the trouble of lot of if explanation I had before?

No, it Won’t injury The Game since When The round Is end The Clone will certainly Be destroyed Which Will likewise Destroy The Module script So. It do not do it Lag The Game.