Need help understanding error

  1. What do you want to achieve? a classic sword fighting game

  2. What is the issue? no matter how many players there are the game doesn’t start and an error pops up and I have absolutely no idea what it means.
    the error:

  3. What solutions have you tried so far? I didn’t find anything on the internet and a few similar topics on the forum but nothing helped.

the code where it errors

	repeat wait(1) until game.Players >= 2 

please note that I’m new to scripting and I was following a tutorial (with explanations) but I couldn’t understand the issue or the error I was receiving. any help is appreciated

Simple! just replace game.Players with #game.Players:GetPlayers()
Hope this helps!

1 Like

Did you mean?

#game.Players:GetPlayers() >= 2 

game.Players is a folder that contains the players but you are not using any function in it so you have to use :GetPlayers () and it will return a table with all the players currently on the server. And the # operator is the length of the table.

2 Likes

thank you so much, it works! (char limit)

1 Like

thanks for the explanation, I think I get it now and it worked! thank you so much!

1 Like

Adding on to explain the error. game.Players is an Instance (thing). And you compared a number to a thing. (Scripts don’t like that) When you do the function :GetPlayers() it returns a table.
When you do #table it returns the amount of entries in the table. Meaning that when you do

#game.Players:GetPlayers()

It shows the amount of players in the game. Which is a number! And now you can compare them together! (Scripts like this.)

1 Like

thank you so much for the explanation, the script works now!

2 Likes