Heyo made a module script that manages a match on the server I tried leaving comments to explain what I’ll use them for and yeah I plan to make a very simillar module except on the client not sure if that’s necessary though.
local MatchManager = {}
local Main = require(game:GetService("ReplicatedStorage").Modules.Universal.Main)
local Modules = Main.Modules
local Player1 = Main.Players:GetChildren()[1]
local Player2 = Modules.NPCController:MakeNPC()
local Stage
local Time = 0
local Rounds = 0
local CurrentRound = 0
local Stages = Main.ServStorage.Stages
--| Prepares the match by spawning stage, setting up variables and firing clients
--| So that the client can do some prep stuff
function MatchManager.PrepareMatch(Selections)
warn("Preparing Match")
Stage = SpawnStage(Selections.Stage)
end
--| Starts the match, fireclients to tell them the match started
--| and keeps track of the match (time and determining who won)
function MatchManager.StartMatch()
end
--| Ends and cleans up the match
function MatchManager.EndMatch()
end
--| Spawns the given stage
function SpawnStage(StageName)
local StageModel
local Camera = Instance.new("Part")
Camera.Name = "Camera"
Camera.Anchored = true
Camera.Transparency = 1
Camera.CanCollide = false
if StageName == "Random" then
local RandomNumber = math.random(1,#Stages:GetChildren())
StageModel = Stages:GetChildren()[RandomNumber]:Clone()
elseif StageName ~= "Random" then
if Stages:FindFirstChild(StageName) then
StageModel = Stages:FindFirstChild(StageName):Clone()
else
warn("Stage "..StageName.." couldn't be found!")
end
elseif StageName == nil or StageName == "" then
warn("No stage name was provided")
end
if not StageModel:FindFirstChild("StartingPositions") or not StageModel:FindFirstChild("MiddlePoint") or not StageModel:FindFirstChild("Bounds") then
warn("Stage is missing parts")
end
Camera.Parent = StageModel
StageModel.Parent = workspace.Game.Stage
if StageModel then
return StageModel
end
end
--| Adding values/setting up signals for the players
function SetupPlayers()
end
return MatchManager