Problem with ends

I am trying to make a round system from a tutorial, and ended up adding new code to have players spawn at random spawn locations instead of 1 single place. My problem is these 3 ends after. It won’t go on the the part where it updates the status value because it ends prematurely. How can I change this?

local roundlength = 1

local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status

inround.Changed:Connect(function()
	
	if inround.Value == true then
		
		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local spawns = workspace.Map.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #spawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = spawns[num].CFrame
		end
		
	else
		
		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #LobbySpawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = LobbySpawns[num].CFrame
		
		
	end
	
end

end)



local function Round()
	
	while true do
		
		inround.Value = false
		
		for i = intermission,0,-1 do
			
			
			status = "Game will start in "..i.." seconds!"
			wait(1)
		end
		
		inround.Value = true
		for i = roundlength,0,-1 do


			status = "Game will end in "..i.." seconds!"
			wait(1)
		end
		
		
	end
	
	
end

spawn(Round)```

Could you explain a little more in detail what you’re trying to achieve? Thanks in advance!

1 Like

em
maybe this is the issue?

1 Like

everything after
image
in this script is supposed to change the game status which is tied to a textlabel. It never gets to that point though because I have these here
image
which tells it to end before it can get to that section and thusly the status never changes, the round system itself functions but the text does not update and count down

It’s spelled correctly and it is lowercase, I don’t see anything that indicates it’s a problem

theres no “intermission” in the script, i checked using Find
em

I set it up and the intermission is not a valid variable.

image

i hope this works now

local roundlength = 1
local intermission = 1
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status

inround.Changed:Connect(function()

	if inround.Value == true then

		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local spawns = workspace.Map.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #spawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = spawns[num].CFrame
		end

	else

		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #LobbySpawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = LobbySpawns[num].CFrame


		end
	end
end)
function Round()

	while true do

		inround.Value = false

		for i = intermission,0,-1 do


			status = "Game will start in "..i.." seconds!"
			wait(1)
		end

		inround.Value = true
		for i = roundlength,0,-1 do


			status = "Game will end in "..i.." seconds!"
			wait(1)
		end


	end


end

spawn(Round)

devforum glitched the code a bit, fixed it.

It kinda hurts my eyes since i’m used to my way of organizing scripts but I believe it could be since your game length is set to 1 second?

local roundlength = 1

image

I tried this, still no errors and yet again the rounds themselves work but the text doesn’t change

Figured it out but I am not quite sure if I could be wrong.

Change “intermission” to the roundlength variable and see if that works.

I tried that to speed up the testing process just to see if I would teleport back and forth. It doesn’t work no matter what I set them to

Maybe if you sent us the whole thing we could figure it out? Just by taking a glance at the code I can’t really seem to figure out what’s wrong besides the fact that intermission is not defined.

There’s only one place I could do that, tried it and nothing changed aside from how long it waits, no fixes to the text

What do you mean the whole thing? Like the place?

Well, whole place would be great, but I mean just some screenshots of the workspace or anything that the script could be linked to.

What does spawn(round) do? I’m not a pro so I’m not familiar with how spawn fires.
Does it only fire once? If it only fires the one time then the round function only fires once.

This is the text i’m trying to change
image

It has a localscript inside of it that looks like this so it updates when the status value changes


text.Text = game.ReplicatedStorage.Status.Value

game.ReplicatedStorage.Status.Changed:Connect(function()
	
	text.Text = game.ReplicatedStorage.Status.Value
	
end)```

![image|186x66](upload://nqLNapMllJbWChaM3l3UcljfTYf.png)

lol i think i know the error, really simple.

local roundlength = 1
local intermission = 1
local inround = game.ReplicatedStorage.Inround
local status = game.ReplicatedStorage.Status

inround.Changed:Connect(function()

	if inround.Value == true then

		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local spawns = workspace.Map.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #spawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = spawns[num].CFrame
		end

	else

		task.wait(1) -- Can be removed later


		local Players = game:GetService("Players")

		local LobbySpawns = workspace.Lobby.Spawns:GetChildren()
		local plrList = Players:GetPlayers()

		task.wait(2) -- Can be removed later

		for _, plr in pairs(plrList) do
			local num = math.random(1, #LobbySpawns)
			local rootPart = plr.Character.HumanoidRootPart
			print(plr)

			rootPart.CFrame = LobbySpawns[num].CFrame


		end
	end
end)
function Round()

	while true do

		inround.Value = false

		for i = intermission,0,-1 do


			status.Value = "Game will start in "..i.." seconds!"
			wait(1)
		end

		inround.Value = true
		for i = roundlength,0,-1 do


			status.Value = "Game will end in "..i.." seconds!"
			wait(1)
		end


	end


end

spawn(Round)
1 Like