How could i save a player's inventory and skins using datastores?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to achieve something like how forsaken saves your characters, your character skins, and what you have equipped

  1. What is the issue? Include screenshots / videos if possible!

I’m struggling to find any solutions on my issue

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried to see if tables would work but it feels wrong to use a table to store the current thing equipped and the player’s inventory. I’ve tried YouTube tutorials but they don’t help

What’s wrong with storing tables?

1 Like

I’m not really sure on how I could fetch the table data and apply it

Do you know how to use DataStoreService?

If not, check out ProfileStore!

Kinda, I’m not sure on how I could retrieve a datastore though

I’d recommend using ProfileStore, but here’s a rough example on how to get data if you plan on writing your own code to handle it:

-- Options --
local GET_MAX_ATTEMPTS = 3

-- Services --
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

local playerDataStore = DataStoreService:GetDataStore("PlayerData")

local function getPlayerData(userId: number)
	for _ = 1, GET_MAX_ATTEMPTS do
		local success, data, keyInfo: DataStoreKeyInfo = pcall(playerDataStore.GetAsync, playerDataStore, "Player"..userId)
		if success then
			return data, keyInfo
		end
		warn(data)
	end
end

Players.PlayerAdded:Connect(function(player)
	local playerData = getPlayerData(player.UserId)
	if not playerData then
		return
	end

	print(playerData)
end)
1 Like

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