How can i make 3 for loops run after each other?

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)

dont wrap it in spawn(function() thread

i tried that already it just didnt work either still same error

considering as u said

you are parenting everything in the same folder in ur code

._. i need to read my code better HOW THE HELL DID I MISS THAT?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.