function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "Killing"
local kills = Instance.new("IntValue")
kills.Name = "KOs"
kills.Value = 0
kills.Parent = stats
while true do
if newPlayer.Character ~= nil then break end
wait(5)
end
local humanoid = newPlayer.Character.Humanoid
humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end )
newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
stats.Parent = newPlayer
end
function Send_DB_Event_Died(victim, killer) local killername = "no one" if killer ~= nil then killername = killer.Name end print("DIED EVENT: ", victim.Name, " KILLED by ", killername)
if shared["deaths"] ~= nil then
shared["deaths"](victim, killer)
print("SENT DB DEATH EVENT")
end
end
function Send_DB_Event_Kill(killer, victim) print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name) if shared["kills"] ~= nil then shared["kills"](killer, victim) print("SENT DB KILL EVENT") end end
function onHumanoidDied(humanoid, player) local stats = player:findFirstChild("Killing") if stats ~= nil then
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
Send_DB_Event_Died(player, killer)
handleKillCount(humanoid, player)
end
end
function onPlayerRespawn(property, player)
if property == "Character" and player.Character ~= nil then
local humanoid = player.Character.Humanoid
local p = player
local h = humanoid
humanoid.Died:connect(function() onHumanoidDied(h, p) end )
end
end
function getKillerOfHumanoidIfStillInGame(humanoid)
local tag = humanoid:findFirstChild("Tag")
if tag ~= nil then
local killer = tag.Value
if killer.Parent ~= nil then
return killer
end
end
return nil
end
function handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("Killing") if stats ~= nil then if killer ~= player then if stats.Parent.Data.Beli.Value == 0 then stats.Parent.Data.Beli.Value = stats.Parent.Data.Beli.Value + 25 end if stats.Parent.Data.Beli.Value > 0 and stats.Parent.Data.Beli.Value < 1000 then stats.Parent.Data.Beli.Value = stats.Parent.Data.Beli.Value + 100 end if stats.Parent.Data.Beli.Value > 1001 and stats.Parent.Data.Beli.Value < 10000 then stats.Parent.Data.Beli.Value = stats.Parent.Data.Beli.Value + 1000 end if stats.Parent.Data.Beli.Value > 10001 then stats.Parent.Data.Beli.Value = stats.Parent.Data.Beli.Value + 5000 end
if stats.Parent.Data.Bounty.Value >= 0 then
stats.Parent.Data.Bounty.Value = stats.Parent.Data.Bounty.Value + 1
meh = humanoid.Parent.Name
if game.Players:findFirstChild(meh).Data.Bounty.Value < 0 then
stats.Parent.Data.Bounty.Value = stats.Parent.Data.Bounty.Value + 2
end
if stats.Parent.Data.Bounty.Value < 0 and game.Players:findFirstChild(meh).Data.Bounty.Value > 5 and game.Players:findFirstChild(meh).Data.Bounty.Value <= 25 then
game.Players:findFirstChild(meh).Data.Bounty.Value = game.Players:findFirstChild(meh).Data.Bounty.Value - 5
end
if stats.Parent.Data.Bounty.Value < 0 and game.Players:findFirstChild(meh).Data.Bounty.Value > 25 and game.Players:findFirstChild(meh).Data.Bounty.Value <= 100 then
game.Players:findFirstChild(meh).Data.Bounty.Value = game.Players:findFirstChild(meh).Data.Bounty.Value - 25
end
if stats.Parent.Data.Bounty.Value < 0 and game.Players:findFirstChild(meh).Data.Bounty.Value > 100 then
game.Players:findFirstChild(meh).Data.Bounty.Value = game.Players:findFirstChild(meh).Data.Bounty.Value - 100
end
end
Send_DB_Event_Kill(killer, player)
end
end
end
game.Players.ChildAdded:connect(onPlayerEntered)
