This is what I got, I'm trying to make a battling game, so basically, I'm putting a tag into players who is battling when they are teleported in to the battle zone. So when someone died, the tag will be remove when they are spawned in the lobby so if who ever have the tag, it means that they are still in the game. the problem is that I'm trying to make a last survivor but I'm not sure how to count the number of players with tag.
local stat = game.ReplicatedStorage:WaitForChild("Stats")
for i, plar in pairs(game.Players:GetChildren())do
if plar.Character then
plar.Character.HumanoidRootPart.CFrame = spawns[1].CFrame
table.remove(spawns,1)
local gametag = Instance.new("BoolValue")
gametag.Name = "GameTag"
gametag.Parent = plar.Character -- Add tag to the players
end
end
local gamecountdown = 20
repeat wait(1)
stat.Value = "Time Left: "..gamecountdown
local player = game.Players:GetChildren()
for i = 1, #player do
local v = player[i] -- making a table of players
print(player)
if v.Character:FindFirstChild("GameTag") then -- getting only the players with tag in the table
-- See if there is only 1 player with a tag
if #v == 1 then -- error: attempt to get length of an Instance Value
local DataStore2 = require(1936396537) -- Datastore2 stuff
local datagold = DataStore2("Golds", v)
stat.Value = "Winner: "..v.Name
datagold:Increment(5)
break
elseif #v == 0 then -- if the 2 last player kill each other at the same time
stat.Value = "Everyone died..."
break
end
end
end
gamecountdown = gamecountdown - 1
until gamecountdown == 0
-- The aftermath of the match, removing the tag from everyone to make sure that there's none
stat.Value = "Game Ended..."
for _, plr in pairs(game.Players:GetChildren())do
if plr.Character then
plr.Character.HumanoidRootPart.CFrame = game.Workspace.SpawnLocation.CFrame
if plr.Character:FindFirstChild("GameTag")then
plr.Character:FindFirstChild("GameTag"):Destroy()
end
end
end
Ask me any question if there is a variable there that I forgot to include as this is only part of the script. Help please. Thank you!

2 comments
You can easily just check if the players in the game is == 1, use a remote event and function that player. Grab the player client side because you can edit text on there, which I assume that's what you do in this case. If the player is the last standing then give them it. You're also making a game tag with a BoolValue, but not adding it to a surface gui, you're making it fine but you're not making
Why would i need to put it in the surface gui tho? since I'm putting the tag in the player's character and I'm trying to find the number of players with the tag. Because there is battle zone and a lobby zone, sorry if that sort of consufed you.