local Players = game.Players
local Template = Instance.new 'BoolValue'
Template.Name = 'leaderstats'
Instance.new('IntValue', Template).Name = "Kills"
Instance.new('IntValue', Template).Name = "Deaths"
Players.PlayerAdded:connect(function(Player)
wait(1)
local Stats = Template:Clone()
Stats.Parent = Player
local Deaths = Stats.Deaths
Player.CharacterAdded:connect(function(Character)
Deaths.Value = Deaths.Value + 1
local Humanoid = Character:FindFirstChild "Humanoid"
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
local Killer = Child.Value
if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
local Kills = Killer.leaderstats.Kills
Kills.Value = Kills.Value + 1
end
return -- Only one player can get a KO for killing a player. Not 2, not 3. Only one.
end
end
end)
end
end)
end)
game.Players.ChildAdded:connect(function(Player)
local Lead = Instance.new("IntValue",Player)
Lead.Name = "leaderstats"
local Cash = Instance.new("IntValue",Lead)
Cash.Name = "Cash"
Cash.Value = 0
DataStore = game:GetService("DataStoreService"):GetDataStore("SaveCash")
local Key = Player.userId
local Data = DataStore:GetAsync(Key)
if Data then
Cash.Value = Data
end
end)
game.Players.ChildRemoved:connect(function(Player)
local Key = Player.userId
DataStore:SetAsync(Key,Player.leaderstats.Cash.Value)
end)
--Rank script

1 comment
There are way too many things I'd have to point out. You should redo the script and follow a youtube tutorial. I think this is the quickest one but explains it well: https://youtu.be/DkYupSBUpes