Team winner alyways says blue wins

self explanatory when everyone dies it alyways says blue wins, even if the red team wins
no code for you

bump lololol392912939219218381238

Print what the sorted table is.

a[2] > b[2] --what if they were tied?

i already have, tested it with 2 red team members it still says blue wins even if blue resets

instead of sorting the table why not just do if Teams[1][2] > Teams[2][2] then (blue team wins) etc.?

wouldn’t work good and look unadvanced on multiple team rounds

How does v:FindFirstChild("GameTag") work? What is the GameTag object? Do players have this as expected on both teams? As far as I can tell this script should work fine so could be an issue there.

Additionally - is the RedTeam and BlueTeam variable correctly assigned earlier in the script?

gametag is the value that spawns in players once the rounds starts, if they die they lose it.
how would this question solve anything if i even try to delete someone’s gametag blue still wins even in solo

yes they’re serepate teams and they work perfectly fine

I ran your script in my own studio instance, manually setting the number of players alive.

local Teams = {
	{"blue",2},
	{"red",3},
}
table.sort(Teams, function(a,b)
	return a[2] > b[2]
end)
if Teams[1] then
	print(tostring(Teams[1][1]))
end

It prints that the Red team won, as expected. This means whatever issue is occurring, it isn’t with the block of code you posted. Double check that the variables are properly assigned to the correct teams, and that the GameTag instance is properly being created and checked. Other than that, you’ll have to post more of your script to get help from us.

am
so turns out i was using player as the table so i swapped the locations and it worked all fine lmao

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.