The code I made, the deaths works but not kills. Can somebody help?
game.Players.PlayerAdded:Connect(function(plr) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr
local kills = Instance.new("IntValue") kills.Name = "KOs" kills.Parent = stats local deaths = Instance.new("IntValue") deaths.Name = "WOs" deaths.Parent = stats plr.CharacterAdded:Connect(function(char) local humanoid repeat humanoid = char:FindFirstChild("Humanoid") wait() until humanoid humanoid.Died:Connect(function(char) deaths.Value = deaths.Value + 1 local tag = humanoid:FindFirstChild("creator") if tag then local killer = tag.Value if killer then killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1 end end end) end)
end)
local currencyName = "DR and DP" local DataStore = game:GetService("DataStoreService"):GetDataStore("UC") game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = player local DP = Instance.new("IntValue") DP.Name = "Points" DP.Parent = stats local DR = Instance.new("IntValue") DR.Name = "Rolls" DR.Parent = stats local ID = currencyName.."-"..player.UserId local savedata = nil pcall(function() savedData = DataStore:GetAsync(ID) end) if savedData ~= nil then DP.Value = savedData DR.Value = savedData print("Data loaded") else DP.Value = 0 DR.Value = 0 print("New player to the game") end end) game.Players.PlayerRemoving:Connect(function(player) local ID = currencyName.." - "..player.UserId DataStore:SetAsync(ID,player.leaderstats[currencyName].Value) end) game:BindToClose(function() for i, player in pairs(game.Players:GetPlayers()) do if player then player:Kick("This Game is Shutting down for saving data and adding updates plz rejoin :D ") end end wait(5) end)
This code does not save, but it should, anyways, it does make a leaderstats appear with two variables, just change it to your stuff and it should work.