Hello I’m making a game using Data store 2, and I’m not sure where to go next.
local ds2 = require(game.ServerScriptService.DataStore2)
ds2.Combine("Data","Coins","Gems","TotalSnow","Blowers","BackPacks")
local function DeSerealize(Items,Type)
if Type == "Blowers" then
for _, tbl in pairs(Items) do
local getfolder = Items[tbl[3]]
if getfolder ~= nil then
getfolder.Equipt.Value, getfolder.Purchased.Value = tbl[1], tbl[2]
end
end
elseif Type == "BackPacks" then
for _, tbl in pairs(Items) do
local getfolder = Items[tbl[3]]
if getfolder ~= nil then
getfolder.Equipt.Value, getfolder.Purchased.Value = tbl[1], tbl[2]
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
wait(1)
local UserId = player.UserId
local stats = player.leaderstats
local Coins = stats.Coins
local TotalSnow = stats.TotalSnow
local blowers = player.Items.Blowers
local BackPacks = player.Items.BackPacks
local Gems = player.leaderstats.Gems
-- load data
local TotalSnowdataStore = ds2("TotalSnow",player)
local CoinsDataStore = ds2("Coins",player)
local GemsDataStore = ds2("Gems",player)
local dataBlowersStore = ds2("Blowers",player)
local dataBackPacksStore = ds2("BackPacks",player)
TotalSnow.Value = TotalSnowdataStore:Get(0)
Coins.Value = CoinsDataStore:Get(0)
Gems.Value = GemsDataStore:Get(0)
local BlowerData = dataBlowersStore:Get({
{
true,true, "BasicShovel"
}
})
local BackPackData = dataBackPacksStore:Get({
{
true,true, "Pockets"
}
})
TotalSnowdataStore:OnUpdate(function(NewValue)
print(NewValue)
TotalSnow.Value = NewValue
end)
CoinsDataStore:OnUpdate(function(NewValue)
print(NewValue)
Coins.Value = NewValue
end)
GemsDataStore:OnUpdate(function(NewValue)
print(NewValue)
Gems.Value = NewValue
end)
dataBackPacksStore:OnUpdate(function(NewValue)
print(NewValue)
DeSerealize(NewValue,BackPacks)
end)
dataBlowersStore:OnUpdate(function(NewValue)
DeSerealize(NewValue,blowers)
print(NewValue)
end)
end)
I have started making the script as seen here.
I’m not sure where I went wrong since I’m stuck here.
If more information is needed just ask.
Can someone with knowledge in data store 2 give me a breif over view of where to go next?
Thanks.