Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Accessing DataStores from LocalScripts?

Asked by 8 years ago

I'm trying to access a datastore from a localscript, but since localscripts don't have access to it, how would I do it? I've tried using RemoveEvents but I don't know how to do it with those.

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

From the server, you will need to create an event to listen for a RemoteFunction to be fired by a client.

RemoteFunction.OnServerInvoke = function()
    return DataStore:GetAsync("key")
end

From the client, you will need to invoke the RemoteFunction:

local data = RemoteFunction:InvokeServer()
Ad

Answer this question