How do i check if data key from datastoreservice loaded?, or if player has no data, Client sided?, from local script.
I don’t believe you can use Data stores from the client. However, you can use a RemoteEvent | Roblox Creator Documentation to send data to the client from the server once their data has loaded. If you don’t know how you can check out the Bindable Events and Functions | Roblox Creator Documentation article.
You cannot use data stores from the client, As @BuilderBob25620 says, You need to create a remote event, If you wanna check if player has no data, use GetAsync(), GetAsync() returns nil if the player has no data.
Example:
if Backpack:GetAsync(player.UserId) == nil then
--code
end
I actually wouldn’t recommend using data from a datastore on the client period. There’s not really any common case where you would require data on the client. And if you do then there’s probably a design issue somewhere.
Either pass the client a copy of the data if you really need to read some data, or use remote events to request a check for some type of data, this way you can validate it on the server.
No im not using data from the server or non like that i just want to check if player has data then the gui would say Creating Data and if it has data then the gui will say loading data.
What I usually do is, I just check if there’s any data in the datastore, and then if there isn’t any I make a copy of a defaultData table. At that point you could just tell the player you’re creating data for them. This is a bad system though because it doesn’t stop you from overwriting data in the event there’s no data available at the time.
Well that’s as simple as just doing :FireClient() before loading/creating data, with an argument, either a bool determining whether player has data, or a string value, and use that on the client to display either loading data or creating data.
EDIT: If you’re stuck at the point of determining if player has data or not, we would have to see your code.