Problem with round system

Many hours writing a couple lines and during my first tests, this came up:

local Duration = 480

local TPLEORET = Vector3.new(-28.5, 0.5, 37.5)

local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")

local Event = RS:WaitForChild("MapChangerClient")
local Event2 = RS:WaitForChild("MapChangerServer")

local ValueFolder = workspace:FindFirstChild("Game")

local findFirstChild = game.FindFirstChild




function TimeRun(TempoRecebido)
	return TempoRecebido - 1
end

function Intervalo(Polar, Map)
	
	--[[CHECKING VALUE FOLDER]]
	
	if ValueFolder~=nil then
		local Time = findFirstChild(ValueFolder, "Time")
		local Generators = findFirstChild(ValueFolder, "Generators")
		local Pages = findFirstChild(ValueFolder, "Pages")
		local Maps = findFirstChild(ValueFolder, "Map")
		local STATE = findFirstChild(ValueFolder, "RoundON")
		--[[CHECK VALUES]]
		if Time and Generators and Pages and Maps and STATE then
			-- RESET EVERYTHING
			Time.Value = 30
			Generators.Value = 0
			Pages.Value = 0
			Maps.Value = ""
			STATE.Value = Polar
			
			while Time.Value>0 do
				Time.Value = TimeRun(Time.Value)
			end
			
		end
	end
	
end

function Partida_Inicio(Polar, Map)
	--[[CHECKING VALUE FOLDER]]

	if ValueFolder~=nil then
		local Time = findFirstChild(ValueFolder, "Time")
		local Generators = findFirstChild(ValueFolder, "Generators")
		local Pages = findFirstChild(ValueFolder, "Pages")
		local Maps = findFirstChild(ValueFolder, "Map")
		local STATE = findFirstChild(ValueFolder, "RoundON")
		--[[CHECK VALUES]]
		
		if Time and Generators and Pages and Maps and STATE then
			
			if STATE == true then
				
				Time.Value = 31
				Generators.Value = 0
				Pages.Value = 0
				Maps.Value = Map
				STATE.Value = false
				
				
				
				
			else
				
				Time.Value = 30
				Generators.Value = 0
				Pages.Value = 0
				Maps.Value = ""
				STATE.Value = true
				
			end
			
		end
	end

end

function Partida_Fim(Polar, Map)
	
	
end






function CHECK(PAGES, GENERATORS, TIME)
	return (PAGES == 8), (GENERATORS==3), (TIME<1)
end



--{{SYSTEM STAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARTTTTT}}

while true do
	warn("ROUND SYSTEM STARTING")
	--[[CHECKING VALUE FOLDER]]
	print("Checking Values")
	if ValueFolder~=nil then
		local Time = findFirstChild(ValueFolder, "Time")
		local Generators = findFirstChild(ValueFolder, "Generators")
		local Pages = findFirstChild(ValueFolder, "Pages")
		local Maps = findFirstChild(ValueFolder, "Map")
		local STATE = findFirstChild(ValueFolder, "RoundON")
		--[[CHECK VALUES]]
		
		if Time and Generators and Pages and Maps and STATE then
			print("VALUES = SUCCESS")
			print("CHECKING ROUND")
			
			
			
			if STATE.Value == true then
				print("ROUND ON, CHECKING STATUS")
				local PC, GC, Ti = CHECK(Pages.Value, Generators.Value, Time.Value)
				print("Pages: "..Pages.Value.. " / Generators: " ..Generators.Value)
				print(PC)
				print(GC)
				if Ti == true then
					if PC == true and GC == true then
						warn("Sobreviventes Vencem")
						Intervalo(false, "")
						warn("Intervalo")
					else
						warn("Monstros Vencem")
						Intervalo(false, "")
						warn()
					end --line 125
				else
					if PC == true and GC == true then
						warn("Sobreviventes Vencem")
						Intervalo(false, "")
						warn("Intervalo")
					else
						Time.Value = TimeRun(Time.Value)
					end --line 125
				end --line 124
			end --line 118			
			if STATE.Value == false then
				Intervalo(false, "")
			end
		end --line 115
		else break
	end	--line 107
end --line 103

(yo wait i found it nvm im stupid) Why dont you just do item:FindFirstChild() ?

1 Like

i read it somewhere that doing game.FindFirstChild is better for the game (did it for the optimization)

add a yield to the last while loop
so try making line 107 into while true do task.wait()

this might fix it

2 Likes

it actually isn’t better for the game at all, I don’t recommend doing that

1 Like

alr! i gotta test it out also ima change the game.FindFirstChild


so it keeps repeating the same warns/prints like it doesnt go to the next prints or warns it just do the loop without going through the IFs

Intervalo = intermission

the script will check if the round is on, the objectives. If the round is on and time is up or the objectives are complete, it calls the intermission that sets everything to 0

if those are the only things in output then it isn’t getting past this if statement

if ValueFolder~=nil then

this means ValueFolder is nil so you might want to use WaitForChild instead of FindFirstChild

local ValueFolder = workspace:WaitForChild("Game")

well, theres also an ‘else’ meant for that ‘if’ that breaks the loop:

if ValueFolder~=nil then

else break

so if the if step isn’t working it should stop the loop

you never put an else break on the first if statement

1 Like

wait sorry I’m wrong, I didn’t see the else at first

the bad if statement is this one!

if Time and Generators and Pages and Maps and STATE then

that means it isn’t finding all of them so use WaitForChild

1 Like

but it breaks here, which is the first if statement

did you edit the code?

You’re right i forgot to add an else on that if statement too. Just made myself look double stupid

the script is confusing too