i want to make my datastore script to load the equipped items, then the gamepasses, then the inventory however when i test this part of my script it all loads into the same singular folder.
Players.PlayerAdded:Connect(function(Player)
local PlayerDataFolder = Instance.new("Folder", Player)
PlayerDataFolder.Name = "PlayerDataFolder"
local Coins = Instance.new("IntValue", PlayerDataFolder)
Coins.Name = "Coins"
local Inventory = Instance.new("Folder", PlayerDataFolder)
Inventory.Name = "Inventory"
local Equipped = Instance.new("Folder", PlayerDataFolder)
Equipped.Name = "Equipped"
local Gamepasses = Instance.new("Folder", PlayerDataFolder)
Gamepasses.Name = "Gamepasses"
local data
local s,e = pcall(function()
data = DatastoreTable(Player.UserId)
end)
if s then
Coins.Value = data.Coins
if data then
spawn(function()
for _, equipped in ipairs(data.Equipped) do
local Value = Instance.new("BoolValue", Equipped)
Value.Name = equipped[1]
Value.Value = equipped[2]
end
end)
spawn(function()
for _, inventory in ipairs(data.Inventory) do
local Value = Instance.new("BoolValue", Equipped)
Value.Name = inventory[1]
Value.Value = inventory[2]
end
end)
spawn(function()
for _, gamepasses in ipairs(data.Gamepasses) do
local Value = Instance.new("BoolValue", Equipped)
Value.Name = gamepasses[1]
Value.Value = gamepasses[2]
end
end)
end
else
warn(e)
end
end)