-- Totti's custom leaderboard print("Leaderboard script version 4.00 loaded") function onPlayerEntered(newPlayer) local TKs = Instance.new("IntValue") TKs.Name = "TeamKills" TKs.Value = 0TKs.Parent = newPlayer local stats = Instance.new("IntValue") stats.Name = "leaderstats" local kills = Instance.new("IntValue") kills.Name = "Points" kills.Value = 0local deaths = Instance.new("IntValue") deaths.Name = "Points" deaths.Value = 0kills.Parent = stats deaths.Parent = stats -- VERY UGLY HACK -- Will this leak threads? -- Is the problem even what I think it is (player arrived before character)? while true doif newPlayer.Character ~= nil then break endwait(5) endlocal humanoid = newPlayer.Character.Humanoid humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end ) -- start to listen for new humanoid newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end ) stats.Parent = newPlayer end--function checkTKs(victim, killer) -- print("CHECK TKS") -- if (killer == nil) then return end -- if (victim == killer) then return end -- if (victim.Team == killer.Team and killer:findFirstChild("TeamKills") ~= nil) then -- killer.TeamKills.Value = killer.TeamKills.Value + 1 -- print("TK++") -- show an appropraite msg -- local msg = Instance.new("Message") -- if (killer.TeamKills.Value == 1) then msg.Text = "Try not to blox your team mates!" end -- if (killer.TeamKills.Value == 2) then msg.Text = "WARNING: blox your team, go to jail!" end -- if (killer.TeamKills.Value > 2) then -- Jail time -- msg.Text = "JAIL TIME!" -- killer.Character.Humanoid.Health = 0 -- end -- msg.Parent = killer -- wait(5) -- msg.Parent = nil --end --end function Send_DB_Event_Died(victim, killer) -- killer may be nil local killername = "no one" if killer ~= nil then killername = killer.Name endprint("DIED EVENT: ", victim.Name, " KILLED by ", killername) if shared["deaths"] ~= nil thenshared["deaths"](victim, killer) print("SENT DB DEATH EVENT") endendfunction Send_DB_Event_Kill(killer, victim) print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name) if shared["kills"] ~= nil thenshared["kills"](killer, victim) print("SENT DB KILL EVENT") endendfunction onHumanoidDied(humanoid, player) local stats = player:findFirstChild("leaderstats") if stats ~= nil thenlocal deaths = stats:findFirstChild("Points") kills.Value = kills.Value - 5-- do short dance to try and find the killer local killer = getKillerOfHumanoidIfStillInGame(humanoid) --checkTKs(player, killer) Send_DB_Event_Died(player, killer) handleKillCount(humanoid, player) endendfunction onPlayerRespawn(property, player) -- need to connect to new humanoid if property == "Character" and player.Character ~= nil thenlocal humanoid = player.Character.Humanoid local p = player local h = humanoid humanoid.Died:connect(function() onHumanoidDied(h, p) end ) endendfunction getKillerOfHumanoidIfStillInGame(humanoid) -- returns the player object that killed this humanoid -- returns nil if the killer is no longer in the game -- check for kill tag on humanoid - may be more than one - todo: deal with this local tag = humanoid:findFirstChild("creator") -- find player with name on tag if tag ~= nil thenlocal killer = tag.Value if killer.Parent ~= nil then -- killer still in game return killer endendreturn nilendfunction handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil thenlocal stats = killer:findFirstChild("leaderstats") if stats ~= nil thenlocal kills = stats:findFirstChild("Points") if killer ~= player thenkills.Value = kills.Value + 10elsekills.Value = kills.Value - 5endSend_DB_Event_Kill(killer, player) endendendgame.Players.ChildAdded:connect(onPlayerEntered) --------------------------------------------------------------------------------------------------------------------------------------Thats the leaderboard.----------------------------------------------------------------------------------------------------------------------------------------Totti's Game Script local game_length = 300 -- every X seconds, end the game, show a message, regen the map, rebalance teams, cause MASSIVE LAG message = nilfunction showMessage(text) -- This function flashes a message to all players -- Clear the message with hideMessage() hideMessage() -- Never show more than one message at a time if message == nil then message = Instance.new("Message") end -- only make a message if we don't have a message object lying around message.Text = text message.Parent = game.Workspace endfunction hideMessage() if message == nil then return endmessage.Parent = nilendfunction clearPlayerInfo() -- resets KOs and WOs local players = game.Players:children() for i = 1, #players doif (players[i]:findFirstChild("leaderstats") ~= nil) and (players[i].leaderstats.KOs ~= nil) then players[i].leaderstats.KOs.Value = 0 endif (players[i]:findFirstChild("leaderstats") ~= nil) and (players[i].leaderstats.Wipeouts ~= nil) then players[i].leaderstats.Wipeouts.Value = 0 endendendfunction getWinnerInfo() -- returns a string that we display to everyone about who the winner is -- in case of tie, no one wins. if someone wants to code something better, be my guest. local highscore = 0local winner = "No one" local tie = falselocal players = game.Players:children() for i = 1, #players dolocal pscore = -1if players[i]:findFirstChild("leaderstats") ~= nil thenif players[i].leaderstats.Points ~= nil thenpscore = players[i].leaderstats.Points.Value endendif pscore == highscore thentie = trueendif pscore > highscore then-- new highscore highscore = pscore winner = players[i].Name tie = falseendendif tie == true then return "There was a tie. How boring." endlocal text = string.format("%s %s %d %s", winner, "wins with", highscore, "points!") return text endfunction getWinningTeamString() local red = 0local blue = 0local p = game.Players:children() for i=1,#p doif (p[i].TeamColor == game.Teams:findFirstChild("Blue zenxers").TeamColor) thenif (p[i]:findFirstChild("leaderstats") ~= nil and p[i].leaderstats.KOs ~= nil) thenblue = blue + p[i].leaderstats.KOs.Value endendif (p[i].TeamColor == game.Teams:findFirstChild("Red zenxons").TeamColor) thenif (p[i]:findFirstChild("leaderstats") ~= nil and p[i].leaderstats.KOs ~= nil) thenred = red + p[i].leaderstats.KOs.Value endendendif (red == blue) then return "Red and Blue tied. How boring!" endif (red > blue) then return string.format("Red won the match by %d points!", red - blue) endreturn string.format("Blue won the match by %d points!", blue - red) endwhile true dowait(game_length - 30) showMessage("30 seconds left until end of game!") wait(5) hideMessage() wait(25) showMessage("Rebalancing teams and launching new game...") wait(5) clearPlayerInfo() game.Teams:rebalanceTeams() hideMessage() end--------------------------------------------------------------------------------------------------------------------------------------Thats the game script.