Datastore not loading inventory?

I’m essentially trying to create a saving inventory called “Relics”. When a player joins, it doesn’t create any values in the “Relics” folder. There is no error message.


local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetOrderedDataStore("Points")
local minutesStore = DataStoreService:GetOrderedDataStore("Minutes")
local RelicsStore = DataStoreService:GetDataStore("Relics")

	local leaderstats ="Folder", Player)
	leaderstats.Name = "leaderstats"
	local Relics ="Folder", Player)
	Relics.Name = "Relics"
	local Points ="IntValue", leaderstats)
	Points.Name = "Points"
	local MinutesPlayed ="IntValue", leaderstats)
	MinutesPlayed.Name = "Minutes Played"
	local MaxScraps ="IntValue", Player)
	MaxScraps.Name = "MaxScraps"
	MaxScraps.Value = 3
	local Scraps ="IntValue", Player)
	Scraps.Name = "Scraps"
	Scraps.Value = 0
	local AccumulatedPoints ="IntValue", Player)
	AccumulatedPoints.Name = "AccumulatedPoints"
	local AccumulatedMinutes ="IntValue", Player)
	AccumulatedMinutes.Name = "AccumulatedMinutes"
	local AllPoints
	local AllMinutes
	local RelicInventory
	local success, response = pcall(function()
		AllPoints = pointsStore:GetAsync(Player.Name)
		AllMinutes = minutesStore:GetAsync(Player.Name)
		RelicInventory = RelicsStore:GetAsync(Player.UserId)
	AccumulatedPoints.Value = AllPoints or 0
	AccumulatedMinutes.Value = AllMinutes or 0
	if RelicInventory then
		for i, v in pairs(RelicInventory) do
			local Relic ="ObjectValue", Relics)
			Relic.Name = v
	local OldPoints = Points.Value
	local NewPoints
		NewPoints = Points.Value
		local Difference = NewPoints - OldPoints
		game.ReplicatedStorage.MoneyChanged:FireClient(Player, Difference)
		OldPoints = NewPoints

	pointsStore:SetAsync(Player.Name, Player.AccumulatedPoints.Value)
	minutesStore:SetAsync(Player.Name, Player.AccumulatedMinutes.Value)
	local RelicInventory = {}
	for i, v in pairs(RelicInventory) do
		table.insert(RelicInventory, v.Name)
	RelicsStore:SetAsync(Player.UserId, RelicInventory)

Make sure you’re parenting the values to the relics folder itself.


local MaxScraps ="IntValue", Player)
	MaxScraps.Name = "MaxScraps"
	MaxScraps.Value = 3
        MaxScraps.Parent = Relics

Also make sure the relics folder is being put somewhere.

Update I realised you’re setting the parent in the parameters, however the API says

Try it underneath how I explained and see if that fixes anything

1 Like

It didn’t work. Anything else I could try? Anyways the issue isn’t anything with MaxScraps, it’s just the part where it creates relic values and saves them.

I’ll look into this further, but my second solution is adding print statements, specifically where you’re having the issues. Ex. Maybe a print statements for the values you’re saving/loading. Also, sorry when you say having relics is the issue that it’s not saving in datastore? Or is it that it won’t load upon return?

1 Like

Won’t load upon return. Let me try adding some print statements to figure out the issue. :+1:

I just realize I figured it out… it was a typo. Thanks for your help.

1 Like

No problem :+1:


1 Like

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