for _, player in pairs(contestants) do if #contestants < 2 then local gameresults = player.Character.Name.." wins!" print(gameresults) elseif #contestants >= 2 then local winners = activecontestants print("Winners: "..winners) mapholder:ClearAllChildren() end end
Here's a snippet of my code. How would I get the names of the activecontestants
?
Use a for loop:
local winners = "" for i = 1, #activecontestants do winners = winners .. activecontestants[i].Name if i < #activecontestants - 1 then --add a comma after every entry except the last two winners = winners .. ", " elseif i ~= #activecontestants then --after the second last one, add an "and" winners = winners .. ", and " end end