-- Created by CorruptgoreDev: May 7, 2024
local Players = game:GetService("Players")
local PLAYER = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fldr_RESOURCES = ReplicatedStorage:FindFirstChild("Resources")
local fldr_GAMEMODES = ReplicatedStorage:FindFirstChild("Gamemodes")
local fldr_MODULES = ReplicatedStorage:FindFirstChild("Modules")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local VoteService = game:GetService("VoteService")
local function GetRandomGamemode() -- This function gets 3 random gamemodes
local g_GAMEMODES = fldr_GAMEMODES:GetChildren() -- Get all gamemode modules from the folder
local g_SelectedGamemodes = {} -- Table where all 3 of the randomly selected gamemodes will be in
for i = 1, 3 do -- For loop to get 3 random gamemodes
local INDEX = math.random(1, #g_GAMEMODES) -- Get's a random gamemode, 1 out of the entire length of the gamemodes folder
if INDEX:GetAttribute("PUBLIC") then -- Checking if the gamemode is a public rotation one, if not then do nothing lel
table.insert(g_SelectedGamemodes, g_GAMEMODES[INDEX]) -- Insert the randomly selected gamemode in the table
table.remove(g_GAMEMODES, INDEX) -- Remove the gamemode to prevent it from being chosen again (NO REPEATS NUH UH)
end
end return g_SelectedGamemodes -- Continue the loop until it's reached it's end (loops 3 times for 3 gamemodes) and return the selected gamemodes table
end
local function StartGamemode(GAMEMODE) -- This function starts the selected gamemode
local gm = require(GAMEMODE) -- Requires the gamemode to use (cus that's how module scripts work)
gm.Run() -- UNIVERSAL FUNCTION FOR ALL GAMEMODES TO WORK
end
local function OnGamemodeSelected(GAMEMODE) -- This is the function that starts the winning gamemode after the vote poll is done
StartGamemode(GAMEMODE.Name) -- Uses the StartGamemode() function with the GAMEMODE name
end
local g_SelectedGamemodes = GetRandomGamemode() -- Variable to refernce and store the 3 randomly selected gamemodes
for _, gm in ipairs(g_SelectedGamemodes) do -- For loop to loop through ALL the randomly selected gamemodes
VoteService:CreateVote(gm.Name) -- Casts a vote using VoteService for a gamemode to choose
end
local g_WinningGamemode = VoteService:GetWinningVote() -- Get's the winning vote out of all the options
OnGamemodeSelected(g_WinningGamemode) -- Uses the winning vote for the final selected gamemode to play!
To embed this project on your website, copy the following code and paste it into your website's HTML: