I edited the default linked leaderboard, sorry I can't explain it but I marked the place's I edited so if you want to change them.
004 | function onHumanoidDied(humanoid, player) |
005 | local stats = player:findFirstChild( "leaderstats" ) |
007 | local deaths = stats:findFirstChild( "Deaths" ) |
008 | deaths.Value = deaths.Value + 1 |
012 | local killer = getKillerOfHumanoidIfStillInGame(humanoid) |
014 | handleKillCount(humanoid, player) |
018 | function onPlayerRespawn(property, player) |
021 | if property = = "Character" and player.Character ~ = nil then |
022 | local humanoid = player.Character.Humanoid |
025 | humanoid.Died:connect( function () onHumanoidDied(h, p) end ) |
029 | function getKillerOfHumanoidIfStillInGame(humanoid) |
034 | local tag = humanoid:findFirstChild( "creator" ) |
039 | local killer = tag.Value |
040 | if killer.Parent ~ = nil then |
048 | function handleKillCount(humanoid, player) |
049 | local killer = getKillerOfHumanoidIfStillInGame(humanoid) |
050 | if killer ~ = nil then |
051 | local stats = killer:findFirstChild( "leaderstats" ) |
053 | local kills = stats:findFirstChild( "Kills" ) |
054 | local cash = stats:findFirstChild( "Cash" ) |
055 | if killer ~ = player then |
056 | kills.Value = kills.Value + 1 |
057 | cash.Value = cash.Value + 100 |
059 | kills.Value = kills.Value - 1 |
066 | function findAllFlagStands(root) |
067 | local c = root:children() |
069 | if (c [ i ] .className = = "Model" or c [ i ] .className = = "Part" ) then |
070 | findAllFlagStands(c [ i ] ) |
072 | if (c [ i ] .className = = "FlagStand" ) then |
073 | table.insert(stands, c [ i ] ) |
078 | function hookUpListeners() |
080 | stands [ i ] .FlagCaptured:connect(onCaptureScored) |
084 | function onPlayerEntered(newPlayer) |
086 | if CTF_mode = = true then |
088 | local stats = Instance.new( "IntValue" ) |
089 | stats.Name = "leaderstats" |
091 | local captures = Instance.new( "IntValue" ) |
092 | captures.Name = "Captures" |
096 | captures.Parent = stats |
102 | if newPlayer.Character ~ = nil then break end |
106 | stats.Parent = newPlayer |
110 | local stats = Instance.new( "IntValue" ) |
111 | stats.Name = "leaderstats" |
113 | local kills = Instance.new( "IntValue" ) |
117 | local deaths = Instance.new( "IntValue" ) |
118 | deaths.Name = "Deaths" |
121 | local cash = Instance.new( "IntValue" ) |
126 | deaths.Parent = stats |
133 | if newPlayer.Character ~ = nil then break end |
137 | local humanoid = newPlayer.Character.Humanoid |
139 | humanoid.Died:connect( function () onHumanoidDied(humanoid, newPlayer) end ) |
142 | newPlayer.Changed:connect( function (property) onPlayerRespawn(property, newPlayer) end ) |
145 | stats.Parent = newPlayer |
149 | function onCaptureScored(player) |
151 | local ls = player:findFirstChild( "leaderstats" ) |
152 | if ls = = nil then return end |
153 | local caps = ls:findFirstChild( "Captures" ) |
154 | if caps = = nil then return end |
155 | caps.Value = caps.Value + 1 |
159 | findAllFlagStands(game.Workspace) |
161 | if (#stands > 0 ) then CTF_mode = true end |
162 | game.Players.ChildAdded:connect(onPlayerEntered) |