Offline Player's Leaderstats

Hello, can someone help me with getting Offline player’s Bool value (with datastore)?

  1. What do you want to achieve?
    I want to get the offline players bool value and if its true it will do something. Basicly I want to get a True/False word from the offline player.

  2. What is the issue?
    I have no clue how to solve this.


local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStore")

	local Leaderstats ="Folder")
	Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player

	local IsVip ="BoolValue")
	IsVip.Name = "IsVip"
	IsVip.Parent = Leaderstats

	local IsVipData

	local Success, ErrorMessage = pcall(function()
		IsVipData = DataStore:GetAsync(Player.UserId.."-IsVipData")


		DataStore:SetAsync(Player.UserId.."-IsVipData", Player.leaderstats.IsVip.Value)

--------Now tricky part comes:

-- offline player is called "DavidLolHun"
local Name = "DavidLolHun"

if DavidLolHun.leaderstats.IsVip.Value == true then
    print("Offline player named DavidLolHun is Vip")
    print("Offline player named DavidLolHun is NOT Vip")
1 Like

You already have your answer with the code you provided. Take a look at this:

What you’re doing here essentially is whenever a player joins, you’re looking to see if that specfic datastore is true or false. This is exactly what you need to do to get the information, with a few changes.

Because you’re looking for a username, you need to convert that to a userId. This can be done with Players:GetUserIdFromNameAsync. Then, simply feed that value into a function similar to your PlayerAdded. If you’re confused on anything let me know and I’ll try and provide a sample, however that should work fine.

Sorry to say I still don’t find the way to make the script. How would you make the script?

There is a topic about it already.

How did you get the player name? Can you get the userId from it? If yes then all you need to do is

local userId = 1234567 --change
local IsVipData

local Success, ErrorMessage = pcall(function()
	IsVipData = DataStore:GetAsync(userId.."-IsVipData")
1 Like

I think he wants to edit their datastore But if he isn’t then he can do this.
But if he wants to edit it there is a plugin that does that
DataStore Editor V3 (Paid)
Free Datastore Editor plugin! [11K installs] [OPEN-SOURCE] (Free)

If he wants to edit it, he can also change the value then use SetAsync.

1 Like

Ye I can get the UserId from it, but the main thing I would ask is when I try your code, it only prints out “nil” and not “false” or “true”. How can I get them printed out?

If it’s nil it means that no data existed.

How do I solve it? xdd You mean if you I write like a “IsVip.Value = false” at the beginning it should work right?

No I mean that the data wasn’t saved / didnt exist.

How do I add a new data to it so it would exist?

How did not my script save it? ooo

This means that the data wasn’t saved, in this part your just loading, did you ever save the data?

Ummm lemme try save and publish the game and see if its all good

Well you see, if you never save the data how do you expect to load it…

well the script I made should save it right?

No the script you made just loads it, to save use SetAsync with the key as the first parameter and the value as the second, SetAsync with the same exact Datastore.

I have saving already but it should work should not it?

Oh wait I didnt see it ;-; I feel blind rn