How can I access a datastore on the client?

I don’t want to save data, just get data. It’s for my admin system. If you need to view the source, here.

3 Likes

You can try remote events to send the information from the client to the server. More info here: Bindable Events and Functions | Roblox Creator Documentation

1 Like

My system relies on module scripts, so I don’t want to use remotes.

What kind of data are you trying to get, if there is no saved data what do you want? Like for example the player’s name or something like that?

The data that’s preset. I literally gave you the source to read. Why does it matter? The question I asked was straightforward.

DataStores are not replicated to the client. You would need to get the data on the server, then either cache it (best option imo) or send it over to the player using remotes.

You can’t use DataStoreService from the client but you can send any necessary information/data from DataStores to local scripts through the use of RemoteEvents/RemoteFunctions.

As I already said, my system relies on modules, so I’m not going to use remotes.

Won’t work. DataStore can't be accessed from the client.

function data.get(player)
	return data_cache[player]
end
1 Like

What I mean by saying to “Cache” the data, I mean to grab the data, then put them into Folders/Values inside the Player. Then using those all you would need to do reference those values.

3 Likes

cant you just have a remote event that fires to a player when they join and then the player handles it and can maybe set for example: “_G.data” = data recieved from server. Then the module can access it?

Since you don’t want to use remote events, you need to put the data in a place where both server and client can access.

Cache the player data in Replicated Storage. I’m sure you can figure it out.

My system tries to stay away from _G, loadstring, getfenv

Im guessing the data is probably a table which would be kinda impossible to store in replicated storage unless you use a hacky way

Could I have like a Shared folder which can hold the data? How would I do that?

You must use Remotes because, in order to even “cache” the value on the client-side, the server has to transmit that data, which must be via Remotes due to FilteredEnabled. Basically, you want the client to get the data, and only the server can do that. Remotes were designed just for this. This isn’t something you can really avoid IIRC.

is the data a table? cause im gonna assume it is. Another hacky alternative is creating a function to encode the data into a string format and another to decode it if that is possible

If you just need to get data, don’t use DataStores, store everything in a script. I assume this is for retrieving what players can access admin.

Yes, it’s a table. How can I encode/decode it?

this could work depending on what type of content is in ur table:

local table = {
name = "blahh",
simething = "blahhhhh"
}

function encode(tab)

local str = ""
for i,v in pairs(tab) do
local new = "type:".. typeof(v).. ","..  i..":"..v.."."
str = str..new

end



end