Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how would i add code to make my saving leaderboard increase the kill amount by 1 when i kill? [closed]

Asked by 4 years ago
game.Players.PlayerAdded:connect(function(player)
local DataStore = game:GetService("DataStoreService")

     local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"

for i,v in pairs(script:GetChildren()) do 
local d = DataStore:GetDataStore(v.Name)
local x = Instance.new("NumberValue",leader)
x.Name = v.Name
x.Value = d:GetAsync(player.UserId) or v.Value



end
end)

game.Players.PlayerRemoving:Connect(function(player)
    for i,v in pairs(script:GetChildren()) do 
        print("Getting")
        local DataStore = game:GetService("DataStoreService")
        local d = DataStore:GetDataStore(v.Name)
        d:SetAsync(player.UserId, player.leaderstats[v.Name].Value)
        print("Saved")
    end
end)

the intvalue for the stats was put inside the script

0
its not really mine i just baught a free model with the script inside go3jack 1 — 4y

Closed as Not Constructive by JesseSong

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?