My game called Brother Minigames that I tried to do at Roblox is almost over. But everyone knows this, all maps are randomly selected in every minigame game. I succeeded in this system by working a little.
I just wrote this code:
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)
local RemoteFunction = ReplicatedStorage:WaitForChild(“GameStatus”) --Create a RemoteFunction in ReplicatedStorage called GameStatus
local Status = “Loading Game” --The variable for the game status.
local CurrentMap;
local Maps = {
{
StartText = "The Game is started! Finish the parkour quick!"; --The text when they start
Name = "The Death Block"; --Name of the mini game
Author = "ProGamerKuzey_C"; --Who made the mini game
Description = "In this mini game, you have to finish the course in the fastest way. The winner of the first game is considered to have won.";
StartText = "The Game is started! Finish the parkour quick!"; --The text when they start
Initialize = function() --Before the game starts
wait(4)
end;
Begin = function() --Code to make the game start
game.Workspace.Minigame1start.CanCollide = false
for _,v in pairs (Players:GetPlayers()) do
local Char = v.Character
local Root = Char and Char:FindFirstChild("HumanoidRootPart")
if Root then
Root.CFrame = workspace.Teleporters.Map1.CFrame
end
end
end;
End = function() --Code when the game finishes
game.Workspace.Minigame1start.CanCollide = true
for _,v in pairs (Players:GetPlayers()) do
v:LoadCharacter()
end
end
};
}
math.randomseed(tick())
function RemoteFunction.OnServerInvoke(Player, Function) --When the Client requests the status
if Function == “GetStatus” then
return Status --Return the client the data.
end
end
local function UpdateStatus(NewStatus)
Status = NewStatus
for _,Player in pairs (Players:GetPlayers()) do --Go through all the players.
RemoteFunction:InvokeClient(Player, Status) --Send the data to the client
end
end
local function SelectGame()
CurrentMap = Maps[math.random(1, #Maps)]
UpdateStatus("Map Selected: "..CurrentMap.Name.." Map By: "..CurrentMap.Author)
wait(5)
UpdateStatus(CurrentMap.Description)
CurrentMap.Initialize()
for i = 1,3 do
UpdateStatus(i)
wait(1)
end
UpdateStatus(CurrentMap.StartText)
CurrentMap.Begin()
wait(1)
for i = 1, 10 do
UpdateStatus("Game In Progress "..10 - i)
wait(1)
end
CurrentMap.End()
end
local function NewRound()
UpdateStatus(“Loading”)
wait(2)
for i = 0, 15 do
UpdateStatus("Intermission "..15 - i)
wait(1)
end
UpdateStatus("Selecting Game")
wait(5)
SelectGame()
end
while true do
NewRound()
end
you all see the code. But I can’t make 2. Minigame, I can only make 1 minigame. Can anybody help with making another minigame?