Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the script not checking if there is less than 3 people or not?


	while wait() do
		if game.Players.PlayerCount < 3 then
	script.Parent.Text = "Waiting for 3 players to begin."
wait(1)
	script.Parent.Text = "Waiting for 3 players to begin.."
wait(1)
	script.Parent.Text = "Waiting for 3 players to begin..."
wait(1)
		
else
	
	script.Parent.Text = "Intermission 60"
	wait(1)
	script.Parent.Text = "Intermission 59"
	wait(1)
	script.Parent.Text = "Intermission 58"
	wait(1)
	script.Parent.Text = "Intermission 57"
	wait(1)
	script.Parent.Text = "Intermission 56"
	wait(1)
	script.Parent.Text = "Intermission 55"
	wait(1)
	script.Parent.Text = "Intermission 54"
	wait(1)
	script.Parent.Text = "Intermission 53"
	wait(1)
	script.Parent.Text = "Intermission 52"
	wait(1)
	script.Parent.Text = "Intermission 51"
	wait(1)
	script.Parent.Text = "Intermission 50"
	wait(1)
	script.Parent.Text = "Intermission 49"
	wait(1)
	script.Parent.Text = "Intermission 48"
	wait(1)
	script.Parent.Text = "Intermission 47"
	wait(1)
	script.Parent.Text = "Intermission 46"
	wait(1)
	script.Parent.Text = "Intermission 45"
	wait(1)
	script.Parent.Text = "Intermission 44"
	wait(1)
	script.Parent.Text = "Intermission 43"
	wait(1)
	script.Parent.Text = "Intermission 42"
	wait(1)
	script.Parent.Text = "Intermission 41"
	wait(1)
	script.Parent.Text = "Intermission 40"
	wait(1)
	script.Parent.Text = "Intermission 39"
	wait(1)
	script.Parent.Text = "Intermission 38"
	wait(1)
	script.Parent.Text = "Intermission 37"
	wait(1)
	script.Parent.Text = "Intermission 36"
	wait(1)
	script.Parent.Text = "Intermission 35"
	wait(1)
	script.Parent.Text = "Intermission 34"
	wait(1)
	script.Parent.Text = "Intermission 33"
	wait(1)
	script.Parent.Text = "Intermission 32"
	wait(1)
	script.Parent.Text = "Intermission 31"
	wait(1)
	script.Parent.Text = "Intermission 30"
	wait(1)
	script.Parent.Text = "Intermission 29"
	wait(1)
		script.Parent.Text = "Intermission 28"
	wait(1)
	script.Parent.Text = "Intermission 27"
	wait(1)
	script.Parent.Text = "Intermission 26"
	wait(1)
	script.Parent.Text = "Intermission 25"
	wait(1)
	script.Parent.Text = "Intermission 24"
	wait(1)
	script.Parent.Text = "Intermission 23"
	wait(1)
	script.Parent.Text = "Intermission 22"
	wait(1)
	script.Parent.Text = "Intermission 21"
	wait(1)
	script.Parent.Text = "Intermission 20"
	wait(1)
	script.Parent.Text = "Intermission 19"
	wait(1)
	script.Parent.Text = "Intermission 18"
	wait(1)
	script.Parent.Text = "Intermission 17"
	wait(1)
	script.Parent.Text = "Intermission 16"
	wait(1)
	script.Parent.Text = "Intermission 15"
	wait(1)
	script.Parent.Text = "Intermission 14"
	wait(1)
	script.Parent.Text = "Intermission 13"
	wait(1)
	script.Parent.Text = "Intermission 12"
	wait(1)

	script.Parent.Text = "Intermission 11"
	wait(1)
		script.Parent.Tick:Play()
	script.Parent.Text = "Intermission 10"
	wait(1)
	script.Parent.Text = "Intermission 9"
	wait(1)
	script.Parent.Text = "Intermission 8"
	wait(1)
	script.Parent.Text = "Intermission 7"
	wait(1)
	script.Parent.Text = "Intermission 6"
	wait(1)
	script.Parent.Text = "Intermission 5"
	wait(1)
	script.Parent.Text = "Intermission 4"
	wait(1)
	script.Parent.Text = "Intermission 3"
	wait(1)
	script.Parent.Text = "Intermission 2"
	wait(1)
	script.Parent.Text = "Intermission 1"
	wait(1)
	end
	end

Please Help

1 comment

0

the reason theres 135 lines is because I don't know much about for loops to shorten it.

1 answer

✓ Accepted answer

The problem is that PlayerCount is not a property of Players - you're trying to compare something that doesn't exist.

That won't work, and will cause your code to error. Instead, use NumPlayers.

if game.Players.NumPlayers < 3 then
	-->> Code
end

Here's how you use a for loop in terms of numbers:

for Number = StartNumber,EndNumber,Step do
	print(Number)
end

Number is simply a variable - you can change its name to anything that will work for a variable. People commonly use i as the name. In the below code, I make the name Count.

StartNumber and EndNumber are the numbers the loop starts and ends at. Step is the way it goes from the start number to the end number.

Step, by default, is 1. That means it goes up by one every time it loops. If you want to count down instead, like below, you would set it to -1. It doesn't have to be 1 - it can't be any number.

Here's the code to count down:

for Count = 60,1,-1 do
	script.Parent.Text = "Intermission " ..Count -->> Concatenate (add/merge) Count onto the text

	if Count == 10 then -->> If 10 seconds are left
		script.Parent.Tick:Play()
	end

	wait(1)
end

TIP: Format your code properly. You can see in the code above, I have used tab to indent ends and code inside other code.

It is much easier to read and fix your code that way.

-->> Harder to read and understand
if Condition then
	if Condition2 then
	print("Hi!")
end
end
-->> Easier to read and understand
if Condition then
	if Condition2 then
		print("Hi!")
	end
end

Hope I helped!

~TDP

1 comment

0

You're great at teaching me this stuff dude thanks!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.