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

I'm Stuck, I Don't Know How To Save Data!?

Asked by 5 years ago
Edited 5 years ago

I've been trying to save my Data using DataStores but I'm not sure where to start?

Leaderstats

local DataStoreService = game:GetService("DataStoreService")
local ds = DataStoreService:GetDataStore("KillsDataSaver")


game.Players.PlayerAdded:Connect(function(plr)

    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    stats.Parent = plr

    local kills = Instance.new("IntValue")
    kills.Name = "Kills"    
    kills.Parent = stats

    local deaths = Instance.new("IntValue")
    deaths.Name = "Deaths"
    deaths.Parent = stats   

    local gems = Instance.new("IntValue")
    gems.Name = "Gems"
    gems.Parent = stats 

    local coins = Instance.new("IntValue")
    coins.Name = "Coins"
    coins.Parent = stats    

    plr.CharacterAdded:connect(function(char)

        local humanoid

        repeat
            humanoid = char:FindFirstChild("Humanoid")
            wait()
        until humanoid

        humanoid.Died:connect(function()

            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)

1 answer

Log in to vote
0
Answered by 5 years ago

Have you watched this tutorial? https://www.youtube.com/watch?v=DkYupSBUpes

0
I have, I'm looking for a way to save all Stats not just one. If I try using that w/ all of those it will just add my request to Queue. Jomeliter 55 — 5y
Ad

Answer this question