Countdown script won´t work!

my countdown script won´t work!
there is no error in output!

script:

local status = game.ReplicatedStorage.Values:WaitForChild("Status")

local tp = game.Workspace:FindFirstChild("TP1")

local tp2 	= game.Workspace:FindFirstChild("TP2")

local tp3 = game.Workspace:FindFirstChild("TP3")

local tp4 	= game.Workspace:FindFirstChild("TP4")

local inround = game.ReplicatedStorage.Values:WaitForChild("inround")
inround.Changed:Connect(function()
	wait(1)
	if inround.Value == true then
		for i, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame =  tp.Position or tp2.Position or tp3.Position or tp4.Position
		end
	elseif inround.Value == false then
		for i, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame =  game.Workspace:FindFirstChild("SpawnLocation").CFrame
			end
		
		local function intermission()
			while true do
				for i = 10, 1, -1 do
					inround = false
					status.Value = "Starting in: "..i.."seconds!"
					wait(1)
				end
				while true do
					for i = 10, 1, -1 do
						inround = true
						status.Value = "Ending in: "..i.."seconds!"
						wait(1)
					end
					end
				
				spawn(intermission)
			end
		end
	
	end
end)

local script:

local status = game.ReplicatedStorage.Values:WaitForChild("Status")
local inround = game.ReplicatedStorage.Values:WaitForChild("inround")

status.Changed:Connect(function()
	script.Parent.Text = status.Value
end)
1 Like

Your spawn intermission is contained within the intermission function itself. You probably want to move it after the function definition.

well, it stil no works, idk that not might be the error!
i also tryed calling it without that spawn!

why there’s for loop in a while true loop?

1 Like

cuz it runs it, and i also saw in yt and it was working perfectly fine for them… ima try without it then!

i did this

local status = game.ReplicatedStorage.Values:WaitForChild("Status")

local tp = game.Workspace:FindFirstChild("TP1")

local tp2 	= game.Workspace:FindFirstChild("TP2")

local tp3 = game.Workspace:FindFirstChild("TP3")

local tp4 	= game.Workspace:FindFirstChild("TP4")

local inround = game.ReplicatedStorage.Values:WaitForChild("inround")
inround.Changed:Connect(function()
	wait(1)
	if inround.Value == true then
		for i, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame =  tp.Position or tp2.Position or tp3.Position or tp4.Position
		end
	elseif inround.Value == false then
		for i, player in pairs(game.Players:GetPlayers()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame =  game.Workspace:FindFirstChild("SpawnLocation").CFrame
			end
		
			while true do
				for i = 10, 1, -1 do
					inround = false
					status.Value = "Starting in: "..i.."seconds!"
					wait(1)
				end
				while true do
					for i = 10, 1, -1 do
						inround = true
						status.Value = "Ending in: "..i.."seconds!"
						wait(1)
					end
					end
				
			
			end
		
	end
	
	
end)



it this right ?

Right away I would like to educate you a bit, so you get a better understanding of a true/false statement.

If you know a value is a true/false statement (also called a BoolValue), then you can do the following:

-- Instead of
if BoolValue.Value == true then
-- do
if BoolValue then
-- Instead of
if BoolValue.Value == false then
-- do
if not BoolValue.Value then
-- So in your case
if inround.Value then

else -- No need to check if the value is false, since it can only be true or false

end

When that is said, this also goes for other values, if you want to check if it’s present or not.

local Apple = 2
local Banana = nil
local Orange = false
--
if Apple then
-- Apple is not "false or nil". So it will pass a "if" statement.
end
--
if not Banana then
-- Banana is nil. So it will pass a "if not" statement.
end
--
if not Orange then
-- Banana is false. So it will pass a "if not" statement.
end

When that is said, you should have an overall while loop, that handles the round. This loop will update each second, and do everything you want from intermission to round-timer

while true do
	task.wait(1) -- Remove this later, if you're sure that a task.wait() will be there somewhere within this While loop.
	-- Intermission wait for players or something

	-- Create map or something

	-- Teleport players or something

	-- Round start:
	Timer = RoundTimeAmount
	repeat
	  -- Do what you want to do each second in your round here, like updating your timer for the clients.
	task.wait(1)
	CurrentPlayers = #game.Players:GetPlayers() -- You can make this more advanced, to check if they're in the round. This will only check if the amount of players in game is enough.
	Timer -= 1
	until CurrentPlayers <= PlayersToStop or Timer == 0

	-- Round finished, hand out rewards, neutralize players or something
	
	-- Clean up map or something
end
1 Like

try it and see if it doesn’t work then it doesn’t work

u should learn the basics of scripting or find someone who can help you out because making games with youtube scripts is not good because most of the videos are outdated and not optimized

stuff that u should learn if u consider scripting :

if statements
remotes
loops

u can also use chatgpt for learning

bro if i use remote it connects the client and the server, that makes sense!

well, i can make my own countdown gui but, i just wanted to use a yt script…

i used remote event before it worked! but it dint loop me! btw sorry for bad english!

btw ty for that tip, it helps me allot!

YouTube videos can be really good for people, that have a hard time understanding “where do I start” or “how do I make something like this”. When you start out scripting for the very first time, your brain does not have any experience with how to handle programming. Indeed video guides can be outdated, but so can the documentations of some topics online.

It is also easier to find a “bundle of code” through videos, that can directly show you how you can code a specific type of game, like “how to create a simulator”, “how to create a roblox piggy game” or “how to create a round based game” to name a few. And tell you all this information in a way text cannot.

Use if BoolValue then. What you’re using now is basically the same as using if BoolValue.Value == true then which is just longer and makes you seem like you dont understand values

1 Like

if i make my own scipt i need to think what i should like put. and that makes me feel hard to code

When you code your own script, you need to ask yourself. What exactly do I want the script to do? - In every single specific scenario. Let’s take a simple intermission that takes everything into account.

  • A player joined, but they does not count towards “available-players-that-can-play” before:
  • Their data is loaded (if you use DataStore)
  • Their UI is loaded locally (if you want to check for this)
  • Their character is present (if you want to make sure their character is there)
  • Their humanoid is alive/health above 0 (if you want to make sure their character is alive)
local PlayersToStart = 2
local CurrentPlayers = 0

repeat
	CurrentPlayers = 0 -- We set this to 0 each time we loop, so we do not add onto a old loop-value
	for _, Player in Players:GetPlayers() do -- No need to specify ipairs/pairs here, recent change in the Roblox code API
		if not Player:GetAttribute("DataLoaded") then continue end -- This is set to true, when their data is loaded within a our "imaginable" datastore script. And will return nil otherwise. If nil we continue our loop to the next player (if any)
		if not Player:GetAttribute("UILoaded") then continue end -- This is set to true, when the client had fired a remote event to the server, telling the server that the client was done loading in all the UI
		if not Player.Character then continue end -- This will be nil if character is not there
		if not Player.Character:FindFirstChildOfClass("Humanoid") or Player.Character.Humanoid.Health == 0 then continue end -- This will be nil if Humanoid is not present or be true if their health is 0 (dead)
		CurrentPlayers += 1 -- Adds 1 to current players since they passed all our sanity checks.
	end
until CurrentPlayers >= PlayersToStart
1 Like

i am trying to learn more and more scripting so i can be good at scripting… like yea!

but sometimes i forgot what they do like allot of codes!
bc like there is allot of words in the language!

You can always try google the specific scenario you’re trying to get the answer on. Like “Roblox how do I check if a player is dead”, and use that for your intermission (just a example).

I do that, if there is something I’ve forgotten, need a updated summary on, or haven’t done before.

1 Like

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