Honestly I haven't the slightest clue, so I made a little bad script which I think may show what I mean? I hope the person who can handle this script can give me some tips, while handling the script.
Well that this datastore is suppost to do is, to to save all the tools in the player inventory, or just save the tools that are available in game, which will be saved if the player has it in their Backpack, whoopie
local DataStore = game:GetService("DataStoreService"):GetDataStore("ToolData")
Foods = game.ReplicatedStorage.Foods
game.Players.PlayerAdded:connect(function(plr)
LoadItems()
local stats = Instance.new('Folder', plr)
stats.Name = "Tool_Holder"
local Tool = Instance.new('BoolValue', stats)
Tool.Name = "StarbloxLatte"
local Tool2 = Instance.new('BoolValue', stats)
Tool2.Name = "Hot Dog"
local Tool3 = Instance.new('BoolValue', stats)
Tool3.Name = "LollyPop"
local Tool4 = Instance.new('BoolValue', stats)
Tool4.Name = "Chocolate Bar"
local Tool5 = Instance.new('BoolValue', stats)
Tool5.Name = "Gummy Bears"
local Tool6 = Instance.new('BoolValue', stats)
Tool6.Name = "Candy Corn"
local Tool7 = Instance.new('BoolValue', stats)
Tool7.Name = "Gumball"
local Tool8 = Instance.new('BoolValue', stats)
Tool8.Name = "Cone Balloon"
local key = "Player-"..plr.UserId
local savedValues = DataStore:GetAsync(key)
if savedValues then
Tool.Value = savedValues[1]
Tool2.Value = savedValues[2]
Tool3.Value = savedValues[3]
Tool4.Value = savedValues[4]
Tool5.Value = savedValues[5]
Tool6.Value = savedValues[6]
Tool7.Value = savedValues[7]
Tool8.Value = savedValues[8]
else
local Values_To_Save = {
Tool.Value,
Tool2.Value,
Tool3.Value,
Tool4.Value,
Tool5.Value,
Tool6.Value,
Tool7.Value,
Tool8.Value,
}
DataStore:SetAsync(key, Values_To_Save)
end
function LoadItems()
if Tool.Value == true then
Foods:FindFirstChild('StarbloxLatte'):Clone().Parent = plr.StarterGear
elseif Tool2.Value == true then
Foods:FindFirstChild('Hot Dog'):Clone().Parent = plr.StarterGear
elseif Tool3.Value == true then
Foods:FindFirstChild('LollyPop'):Clone().Parent = plr.StarterGear
elseif Tool4.Value == true then
Foods:FindFirstChild('Chocolate Bar'):Clone().Parent = plr.StarterGear
elseif Tool5.Value == true then
Foods:FindFirstChild('Gummy Bears'):Clone().Parent = plr.StarterGear
elseif Tool6.Value == true then
Foods:FindFirstChild('Candy Corn'):Clone().Parent = plr.StarterGear
elseif Tool7.Value == true then
Foods:FindFirstChild('Gumball'):Clone().Parent = plr.StarterGear
elseif Tool8.Value == true then
Foods:FindFirstChild('Cone Balloon'):Clone().Parent = plr.StarterGear
end
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local key = "Player-"..plr.UserId
local Values_To_Save = {
plr.Tool_Holder.Tool.Value,
plr.Tool_Holder.Tool2.Value,
plr.Tool_Holder.Tool3.Value,
plr.Tool_Holder.Tool4.Value,
plr.Tool_Holder.Tool5.Value,
plr.Tool_Holder.Tool6.Value,
plr.Tool_Holder.Tool7.Value,
plr.Tool_Holder.Tool8.Value
}
DataStore:SetAsync(key, Values_To_Save)
end)
