Oh geez almighty
Hm, alright the first thing I notice are the variable warnings, you should be a local variable instead ![]()
Also, why are you changing the Deaths.Value to 0? (Aka subtracting the Deaths.Value from itself)
Next, please don’t use the second parameter when using Instance.new(), it’s slower
This should work, but I’m not exact if it will:
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("IntValue")
Stat.Name = "leaderstats"
Stat.Parent = Player
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Parent = Stat
local Deaths = Instance.new("IntValue")
Deaths.Name = "Deaths"
Deaths.Parent = Stat
if Use_DP then --This is either not a valid variable or you didn't define it right, not enough information
loadStat(player, "Kills", Kills)
loadStat(player, "Deaths", Deaths)
end
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
Deaths.Value = 0
local Cre = Humanoid:FindFirstChild("creator")
if Cre and Cre.Value then
local leaderstats = Cre.Value:FindFirstChild("leaderstats")
if leaderstats then
leaderstats.Kills.Value += 1
leaderstats.Deaths.Value += 2 --Wait why doe
else
Kills.Value = Kills.Value
end
if Use_DP then
saveStat(Cre.Value, leaderstats.Kills.Value, "Kills")
saveStat(Player, Kills.Value, "Kills")
end
end
end)
end)
end)