It was underlined in red when I wrote this:
1 | if Players = = < 5 then |
2 | print ( "not enough players!" ) |
3 | end |
the '<' symbol is underlined in red? how do I fix this?
Essentially you want to run an if statement checking if the player count is lower than 5. You can do this by checking every time a player joins.
01 | local val = 5 -- player limit |
02 |
03 | function check() |
04 | if #game.Players:GetChildren() < val then -- # is essentially converting a value in to number. |
05 | return true |
06 | else |
07 | return false |
08 | end |
09 | end |
10 |
11 | game.Players.PlayerAdded:Connect( function () |
12 | local val 1 = check() -- getting returned value |
13 | if val 1 = = true then -- if there are less than 5 players |
14 | -- execute function |
15 | print ( "Less than 5 players are in" ) |
16 | else |
17 | print ( "More than 5 players are in!" ) |
18 | end |
19 | end ) |
Yay, it's solved. Here's the solution. I made a value in the 'Players' tab, it adds 1 whenever 1 player joins.
1 | local Players = game.Players |
2 | local PlayerNumber = game.Players.PlayerNumber |
3 | Players.PlayerAdded:Connect( function () |
4 | PlayerNumber.Value = PlayerNumber.Value + 1 |
5 | end ) |
This one is the if and then statement, I tried it without the '==' this time.
01 | local map 1 = game.workspace.Map 1 |
02 | local map 2 = game.workspace.Map 2 |
03 | local map 3 = game.workspace.Map 3 |
04 | local Players = game.Players |
05 | local PlayerNumber = game.Players.PlayerNumber |
06 | local playercountdeny = 'not enough players' |
07 | if PlayerNumber.Value < 8 then |
08 | print (playercountdeny) |
09 |
10 | end |