elseif gamemode==2 then
)function getWinningTeamString() local red = 0 local blue = 0 local players = game.Players:GetChildren() local a = 0 if gamemode == 1 then for i=1,#players do if (players[i].TeamColor == game.Teams:FindFirstChild("BLUE TEAM").TeamColor) then if (players[i]:FindFirstChild("leaderstats") and players[i].leaderstats:FindFirstChild("Kills")) then blue = blue + players[i].leaderstats:FindFirstChild("Kills").Value end end if (players[i].TeamColor == game.Teams:FindFirstChild("RED TEAM").TeamColor) then if (players[i]:FindFirstChild("leaderstats") and players[i].leaderstats:FindFirstChild("Kills")) then red = red + players[i].leaderstats:FindFirstChild("Kills").Value end end end elseif gamemode==2 then for i=1,#players do if (players[i]:FindFirstChild("leaderstats") and players[i].leaderstats:FindFirstChild("Kills")) then end end end if gamemode==1 and (red == blue) then return "Stalemate! (Nobody won...)" end if gamemode==1 and (red > blue) then return string.format("Red defeated the opposition by %d points!", red - blue) end if gamemode==1 and (red < blue) then return string.format("Blue defeated the opposition by %d points!", blue - red) end if gamemode==2 then return "The winner is "..value1(username).." with "..value2(kills).." kills!" end end
while true do players = game:GetService("Players"):GetChildren() repeat wait(1) do end until #players>=2 gamemode = 2--math.random(1,2) if gamemode==1 then gamestart(mapstorage.TDM:GetChildren()) elseif gamemode==2 then gamestart(mapstorage.FFA:GetChildren()) end wait(game_length-30) messageEvent:FireAllClients("30 seconds left until the end of this round!",5) script["30seconds"]:Play() wait(30) messageEvent:FireAllClients(getWinningTeamString(),30) -- right here btw -- i cut off the rest since theres no point in displaying it
What you need to do is index the player in your for loop, and then index its properties.
local Players = game:GetService("Players"):GetPlayers() for i = 1, #Players do local plr = Players[i] local leaderstats = plr:FindFirstChild("leaderstats") if leaderstats then local kills = leaderstats:FindFirstChild("Kills") end end
All you will need to do to index the player's name is plr.Name
.