Facebook
From Sweltering Moth, 2 Years ago, written in Lua.
This paste is a reply to leaderstats from olimaly - go back
Embed
Viewing differences between leaderstats and Re: leaderstats
local MoneyStore = game:GetService("DataStoreService"):GetDataStore("MoneyData")
local RebirthStore = game:GetService("DataStoreService"):GetDataStore("RebirthData")
local EyeStore = game:GetService("DataStoreService"):GetDataStore("EyesData")


game.Players.PlayerAdded:Connect(function(plr)
        local leaderstats = Instance.new("Folder")
        leaderstats.Name = "leaderstats"
        leaderstats.Parent = plr

        local money = Instance.new("IntValue")
        money.Name = "Coins"
        money.Value = MoneyStore:GetAsync(plr.UserId) or 0
        money.Parent = leaderstats
        local Rebirths = Instance.new("IntValue")
    Rebirths.Name = "Rebirths"
        Rebirths.Value = RebirthStore:GetAsync(plr.UserId) or 0
        Rebirths.Parent = leaderstats
        local Eyes = Instance.new("IntValue")
        Eyes.Name = "Eyes"
        Eyes.Value = EyeStore:GetAsync(plr.UserId) or 0
        Eyes.Parent = leaderstats


end)

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

        MoneyStore:SetAsync(plr.UserId, plr.leaderstats.Coins.Value)
        RebirthStore:SetAsync(plr.UserId, plr.leaderstats.Rebirths.Value)
        EyeStore:SetAsync(plr.UserId, plr.leaderstats.Eyes.Value)
end)