So, im making a Loading Menu game where I need a Player's Data to load which all the Values are inside a Folder called 'Inventory', which is located in the Player.
local DSService = game:GetService('DataStoreService'):GetDataStore('PlayerData')
game.Players.PlayerAdded:connect(function(plr)
-- Define variables
local uniquekey = 'id-'..plr.userId
local datafolder = script.Inventory
local j = datafolder:Clone()
j.Name = ''..plr.userId..''
local cashvalue = Instance.new('IntValue',j)
local shirtvalue = Instance.new('NumberValue',j)
local pantsvalue = Instance.new('NumberValue',j)
local haircolorvalue = Instance.new('BrickColorValue',j)
local hairvalue = Instance.new('StringValue',j)
cashvalue.Name = 'Cash'
shirtvalue.Name = 'ShirtEquipped'
pantsvalue.Name = 'PantsEquipped'
haircolorvalue.Name = 'HairColor'
hairvalue.Name = 'HairEquipped'
cashvalue.Value = 50000
shirtvalue.Value = 523095212
pantsvalue.Value = 585084183
haircolorvalue.Value = BrickColor.new('Really black')
hairvalue.Value = 'TreckyHair'
j.Parent = plr
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
cashvalue.Value = GetSaved[1]
shirtvalue.Value = GetSaved[2]
pantsvalue.Value = GetSaved[3]
haircolorvalue.Value = GetSaved[4]
hairvalue.Value = GetSaved[5]
else
local NumbersForSaving = {cashvalue.Value, shirtvalue.Value, pantsvalue.Value, haircolorvalue.Value, hairvalue.Value}
DSService:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local SaveTable = {plr[''..plr.userId..''].Cash.Value, plr[''..plr.userId..''].ShirtEquipped.Value, plr[''..plr.userId..''].PantsEquipped.Value, plr[''..plr.userId..''].HairColor.Value, plr[''..plr.userId..''].HairEquipped.Value}
DSService:SetAsync(uniquekey, SaveTable)
end)
The Problem is that it doesn't save.

1 comment
I was testing in Studio, and in-game and this isnt saving still and I don't know why :/ and yes my API Services are on.