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

Detect if there is less than or equal to 1 person left on the team?

Asked by
knotam 3
5 years ago
Edited 5 years ago

I've been trying to make a script that can detect how many people are on a team and if there is less than or equal to one person on a team.

This is what I've gotten so far but have no idea what to do and i'm stuck. Here is the script.

teams = game.GetService("Teams") team1 = teams.Playing local team1players

function onGameEnd()

team1players = team1:GetChildren()

if #team1players < 2 then

print("players less than 2")

end end

1 answer

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

Pretty simple just change < to <=.

teams = game.GetService(“Teams”)  
team1 = teams.Playing  
local team1players

function onGameEnd()

team1players = team1:GetChildren()

if #team1players < 2 then

print(“players less than 2”)

end  
if #team1players <= 1 then

print(“players equal to or less then 1”)

end  
end

You can also find more information here.

0
I changed the code to this change the function to while true do and I still get no output in the console even when Team1Players is less than or equal to one. knotam 3 — 5y
Ad

Answer this question