Round System Not Working

i’m currently rewriting my round system right now but for some reason it doesn’t work, there are no errors or anything

heres the code

local Players = game:GetService("Players")
local GameFolder_Variables = game:GetService("ReplicatedStorage").game

local GameFolder = workspace.game
local Survivors = {}

local Killer = {}
local TweenService = game:GetService("TweenService")

REQUIREDPLAYERS = 1
CHECK_IF_KILLER_ALIVE = false

local SoundService = game:GetService("SoundService")
local Sounds_Group = SoundService.soundsgroup

local tInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local tInfo2 = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local LOBBY_MUSIC_TWEEN_1  = TweenService:Create(Sounds_Group.lobby_theme, tInfo, {Volume = 1.3})
local LOBBY_MUSIC_TWEEN_0  = TweenService:Create(Sounds_Group.lobby_theme, tInfo, {Volume = 0})

Sounds_Group.lobby_theme:Play()
local BadgeService = game:GetService("BadgeService")

Players.PlayerAdded:Connect(function(plr)
	if not plr:FindFirstChild("ValuesFolder") then
		local folder = Instance.new("Folder",plr)
		folder.Name = "ValuesFolder"

		local DiedValue = Instance.new("BoolValue",folder)
		DiedValue.Name = "DiedValue"

		local InMenu = Instance.new("BoolValue",folder)
		InMenu.Name = "InMenu"
		
		local IsKiller = Instance.new("BoolValue",folder)
		IsKiller.Name = "IsKiller"
		
		local IsSurvivor = Instance.new("BoolValue",folder)
		IsSurvivor.Name = "IsSurvivor"
		
	elseif plr:FindFirstChild("ValuesFolder") then
		return
	end
end)

function System()
	if Players.NumPlayers == REQUIREDPLAYERS then
		--repeat task.wait() until Players == REQUIREDPLAYERS
		
		task.wait(GameFolder_Variables.values.TimeBeforeRestarting.Value)
		GameFolder_Variables.values.TimeBeforeRestarting.Value = 3
		
		GameFolder_Variables.values.Time.Value = 120
		
		for _, all_players in pairs(Players:GetPlayers()) do
			if all_players then
				if all_players:FindFirstChild("ValuesFolder") then
					if all_players:FindFirstChild("ValuesFolder").IsKiller.Value == true or all_players:FindFirstChild("values_folder").IsSurvivor.Value == true then
						all_players:FindFirstChild("ValuesFolder").IsSurvivor.Value = false
						all_players:FindFirstChild("ValuesFolder").IsSurvivor.Value = false
					end
				end
			end
		end
		
		repeat task.wait(1) GameFolder_Variables.values.Time.Value -= 1 until
		GameFolder_Variables.values.Time.Value <= 0
		
		LOBBY_MUSIC_TWEEN_0:Play()
		
		if GameFolder_Variables.values.Time.Value == 0 then
			task.wait(1)
			print("Preparing")
			Sounds_Group.tick:Stop()
			Sounds_Group.clock_chime:Play()
		end
		
		
		local chosen = Players:GetChildren()[math.random(1, #Players:GetChildren())]
		
		if chosen then
			if chosen:FindFirstChild("ValuesFolder").IsKiller.Value == false and chosen:FindFirstChild("ValuesFolder").IsSurvivor.Value == false then
				chosen:FindFirstChild("ValuesFolder").IsKiller.Value = true
				chosen:FindFirstChild("ValuesFolder").IsSurvivor.Value = false
				table.insert(Killer, chosen)
			end
		end
		
		if not BadgeService:UserHasBadgeAsync(chosen.UserId,2144098131) then
			BadgeService:AwardBadge(chosen.UserId,2144098131)
		else
			print(chosen.Name.." already has the badge.")
		end
		
		for _, survivor_players in pairs(Players:GetPlayers()) do
			if survivor_players:FindFirstChild("ValuesFolder") then
				if survivor_players:FindFirstChild("ValuesFolder").IsKiller.Value == false and survivor_players:FindFirstChild("ValuesFolder").IsSurvivor.Value == false then
					survivor_players:FindFirstChild("ValuesFolder").IsKiller.Value = false
					survivor_players:FindFirstChild("ValuesFolder").IsSurvivor.Value = true
					table.insert(Survivors, survivor_players)
				end
			end
		end
		
		task.wait(12)
		
		if chosen:FindFirstChild("ValuesFolder").IsKiller.Value == true then
			if chosen.Character then
				chosen.Character:FindFirstChild("HumanoidRootPart").CFrame = GameFolder.warm_killer_spawn.CFrame
			end
		end
	end
end

while true do
	task.wait()
	System()
end

What’s not working about this script? Is something not happening that you want to happen?

yes, it’s not decreasing the number value

Can you be a little more specific of which number?

the function is not decreasing the Time Value

If I’m looking correctly

repeat task.wait(1) GameFolder_Variables.values.Time.Value -= 1 until GameFolder_Variables.values.Time.Value <= 0

This is the part of the code that doesn’t work, is what your saying right?

yes, thats the line that’s not working i guess

Are you using a number value or int value ? Is there any error messages popping up? Because your timer should decrease with that line of code.

i’m using a number value and no, there are no error messages popping up

Try this instead of

if Players.NumPlayers == REQUIREDPLAYERS then

do

if #Players:GetPlayers() == REQUIREDPLAYERS then

or switch this

task.wait(GameFolder_Variables.values.TimeBeforeRestarting.Value)
GameFolder_Variables.values.TimeBeforeRestarting.Value = 3

to

GameFolder_Variables.values.TimeBeforeRestarting.Value = 3
task.wait(GameFolder_Variables.values.TimeBeforeRestarting.Value)

could be that the time on the value at the start is super long ?

If nothing works then add prints to check where the script stops when it reaches your timer.

This runs the system function pretty much continuously. One of the first things the system function is doing is setting the time value to 120, so even if code later on does reduce it, it gets reset to 120.
I would run a function each time a player joins to check if there are enough players (and to check whether a game is in progress already) , and then run system.

No your wrong. Your thinking of Run Service, while true do has to do the whole system function before it redoes the cycle.

Yes you’re right, I was actually thinking they’d used task.spawn to create a new thread.

Not sure if this will make a difference but Players.NumPlayers is deprecated. Try using #Players:GetPlayers() instead.
As @BIULDERBRO has mentioned.

i did everything you said but it still doesn’t work, i tried adding print() and i was met with something, it was continuosly printing but the other codes didnt work
image
image

From the look of it, your repeat loop isn’t running properly. Meaning it is skipping through and system is called continuously via the while loop.
Try this (replacing your current repeat loop).

repeat 
    task.wait(1)
print(GameFolder_Variables.values.Time.Value)
local timeLeft = GameFolder_Variables.values.Time.Value - 1
    GameFolder_Variables.values.Time.Value = timeLeft
until GameFolder_Variables.values.Time.Value <= 0

I guess instead of a repeat try doing a for loop

Ex

for i = Time,0,-1 do
    task.wait(1)
end


where should i put this, on the function or in the while true do

I decided to use my old round system instead, @BIULDERBRO, @Wigglyaa, thanks for trying to help :DD

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