Minigame Round System

Alright so basically I’m trying to make a Minigame Round system but there are two small issues:

  1. The round countdown doesn’t work, this is confusing because the intermission countdown works. I’ve found out that it must have something to do with the countdown script not being enabled because the script says its enabled but it isn’t doing anything.

  2. Round system won’t repeat for some reason it just stays saying “loading…”, the intermission works once and then it stops changing the countdown textbox. This is most likely because of the script not being disabled.

This is my second thing I’ve completely scripted myself so I may not understand certain things, any support is appreciated.

Scripts:

MainScript (In ServerScriptService)

-----[VARIBLES]-----
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:FindFirstChildOfClass("RemoteEvent")
local TeamPlayers = 5
local alwaysTrue = true
local IntermissionTime = 15
local UI = game.StarterGui.PlayerUI
local TimerBox = UI.TimerText
local GSText = UI.GameStatusText
local IntermissionScript = UI.Intermission
local GameTimerScript = UI.TimersScript

---{Dodge Ball}---
local DBScript = game.ServerScriptService.DodgeBallScript
local DBFolder = game.ServerStorage.DodgeBallMG

---{Sword Fight}---
local SFScript = game.ServerScriptService.SwordFightScript
local SFFolder = game.ServerStorage.SwordFightMG


-----[LISTS]-----                                                             (if team then put TeamPlayers varible)
-- Game Format | 1. Game Name  2. Game Time  3. Game Description  4. Team Game  5. # of Winners  6. Multi Mapped  7. Map Folder  8. Script  #. Multi Varients
local DodgeBallMG = {"Dodge Ball", 5, "Dodge the balls to win", true, TeamPlayers, false, DBFolder, DBScript}

local SwordFightMG = {"Dodge Ball", 5, "Be the last one standing", false, 1, false, SFFolder, SFScript}


local MGList = {DodgeBallMG, SwordFightMG}

-----[FUNCTIONS]-----
local function sendToUI ()
	print("working`")
end

local function doMG()
	local gameNum = math.random(1, #MGList)
	while _G.oldGameNum == gameNum do
		local gameNum = math.random(1, #MGList)
	end
	_G.oldGameNum = gameNum
	local gameInUse = MGList[gameNum]
 	_G.MGTime = gameInUse[2]
	local scriptInUse = gameInUse[8]
	local folderInUse = gameInUse[7]
	local dupeMap = folderInUse:clone()
	dupeMap.Parent = workspace
	scriptInUse.Enabled = true
	GameTimerScript.Enabled = true
end

local function Intermission()
	IntermissionScript.Enabled = true
	local eeieie = IntermissionTime + 2
	wait(eeieie)
	IntermissionScript.Enabled = false
end

-----[SCRIPT]-----
while alwaysTrue do
	Intermission()
	doMG()
	wait(_G.MGTime) 
end

Intermission [Disabled] (In the GUI)

local UI = script.Parent
local TimerBox = UI.TimerText
local GSText = UI.GameStatusText
local IntermissionTime = 15

GSText.Text = "Intermission"
local timeSpent = 0
while timeSpent ~= IntermissionTime do
	local timeB4Done = IntermissionTime - timeSpent
	timeSpent = timeSpent + 1
	TimerBox.Text = timeB4Done
	wait(1)
	print(timeB4Done)
end
TimerBox.Text = "Loading..."

TimersScript [Disabled] (Also in the GUI)

print("e")
local IntermissionTime = 15
local UI = game.StarterGui.PlayerUI
local TimerBox = UI.TimerText
local GSText = UI.GameStatusText
local CurrentGameTime = _G.MGTime

GSText.Text = "Game"
print("e2")
local timeSpent = 0
while timeSpent ~= CurrentGameTime do
	local timeB4Done = CurrentGameTime - timeSpent
	timeSpent = timeSpent + 1
	TimerBox.Text = timeB4Done
	wait(1)
	print(timeB4Done)
end

script.Parent.Enabled = false

Also if anyone mentions that I shouldn’t use too many global variables, I know, but I dont know what else to do that isn’t too complex.

Hello! This is unrelated, but using _G is a bad practice. Instead, module scripts are a work around and are faster. I’m currently looking into what could be the problem.

1 Like

So I couldn’t find out why it was wrong so instead of using global variables i found a work around and used a value storage in order to make the countdown work:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Status = ReplicatedStorage:WaitForChild('Status')

local TextStatus = script.Parent.TimerText

TextStatus.Text = Status.Value

Status.Changed:Connect(function()
	TextStatus.Text = Status.Value
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.