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

How do I save Multiple IntValues in a datastore?

Asked by
Kitorari 266 Moderation Voter
8 years ago
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("Point")

game.Players.PlayerAdded:connect(function(player)
    local PointMaster = Instance.new("Folder",player)
    PointMaster.Name = "Points"

    local Points = Instance.new('IntValue',PointMaster)
    Points.Name = "Valu"
    Points.Value = ds1:GetAsync(player.UserId) or 0
    ds1:SetAsync(player.UserId,Points.Value)

local Points = Instance.new('IntValue',PointMaster) 
    Points.Name = "EXP"
    Points.Value = ds1:GetAsync(player.UserId) or 0
    ds1:setAsync(player.UserId,Points.Value)



    Points.Changed:connect(function()
        ds1:SetAsync(player.UserId,Points.Value)
        print("Points Saved!")

        exp.Changed:connect(function()
            ds1:setAsync(player.UserId,exp.Value)
            print("EXP Saved!")
        end)

    end)
end)

game.Players.PlayerRemoving:connect(function(player)
    ds1:SetAsync(player.UserId, player.Points.Points.Value)

    print("Data Saved")

end)
This is what I've tried.

Can someone help or correct this?

1 answer

Log in to vote
0
Answered by 8 years ago

That should work... Unless you want them to be 2 different data stores. This one data store with 2 variables, which would work also.

Ad

Answer this question