Get player values from DataStoreService

So, I’ve been trying to make profile GUI’s which display a player’s stats, like their Level or Experience.
The thing is, I have no idea how to retrieve an offline player’s data/values.

How would I get the values inside a folder, located inside a player from DataStore?
Screenshot 2024-01-12 235032

local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("Levels")
local PlayerService = game:GetService("Players")

function getData(player)

     pcall(function()

          local level = player.Stats.Level.Value
          local exp = player.Stats.Experience.Value

          levelDS:GetAsync(PlayerService:GetUserIdFromNameAsync(script.Parent.NameContainer.Name_1.Text) .. "Level", {level, exp})
          script.Parent.ShowStuff.Text = exp
     end)
end

wait(5)
getData()

This is what I’ve tried, this script gets the UserId using a textlabel with a player’s username, which then tries to get their Stats/Values.

I want to know how I could get a player’s stats/values and display them on textlabels.

If the script above doesn’t make any sense, then its because I don’t know what I am doing.

Use tables for players stats and remotes to replicate stats on client

1 Like

Alright, I made it so that it uses tables for player stats, but how do I use remotes to replicate the stats on a client?
I’m really sorry if im asking too much, I haven’t done this before.

I am using custom functions, example:
Stats.SetValue(player, path, value)
Stats.InsertArray(player, path, table)
taken from replica service

Create functions on server and repeat it on client

Next stage use RemoteEvent to send data on client

Get data on client and set in local data

Or you can just use replica service