Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Make A Script That Will Find The Player Amount From A StringValue?

Asked by 6 years ago

I'm Making A Game That Needs At Least 2 Players To Start, Is There Anyway To Make A Script To Find How Many Players There Is? I Only Have This So Far:

game.players:GetChildren

I'm Not The Best At Scripting

0
check the wiki on making rounds game GamingOverlord756 48 — 6y
0
Thanks! JamiethegreatQ777 16 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

*To turn "Players" into an integer (Number) value instead of a table/array you put a "#" in-front

so if:*

Players = game.Players:GetChildren() -- This is the total ammount of players
"print(Players)"

Output: "AnAnonymousDeveloper, JamieTheGreatQ777"

Players = game.Players:GetChildren() -- This is the total ammount of players
"print(#Players)"

Output: "2"

So you could have it as:

Players = game.Players:GetChildren() -- This is the total ammount of players

if #Players >= 2 then
    GameCanStart = true
end

Hope This Helps! ~ AnAnonymousDeveloper

Ad

Answer this question