LocalStoreService

https://www.roblox.com/library/7975007062/

Introduction

Hello I’m dand, I’ve been scripting for over a year now and I’m starting to create more modules for the community. This project has just been one that has just sat in my Studio until I eventually found it again and decided to open source it.

Why use this module?

This module is to hopefully allow access to datastores on the client for client sided data. I’ve done this by allowing the client to save and load on the server.

Now this might seem like a terrible idea since the client could just spam the store with junk causing server lag and some other problems, a solution I’ve come up with is simple cooldown on both the server and client so you can’t just while true do LocalStore:RequestSet('a','junk') end without any cosquences.

Some examples are you could save settings local to the client such as a Dark Mode, Graphic settings, UI settings etc without saving any valueable information that an exploiter could use to give themselves a massive advantage.

Example

Well first lets get the module

local LocalStoreService = require(game:GetService('ReplicatedStorage'):WaitForChild('LocalStoreService'))

Now to get a store

local LocalStore = LocalStoreService:RequestDataStore()

And to do the equivalent of SetAsync and GetAsync, just do

LocalStore:RequestSet('key', 'value')

LocalStore:RequestGet('key')

Pretty simple, now just a simple usage of it inside a script

local LocalStoreService = require(game:GetService('LocalStoreService'))

local LocalStore = LocalStoreService:RequestDataStore() -- Get LocalStore

local UI = script.Parent -- Define UI
local SettingsFrame = UI:WaitForChild('SettingsFrame') 
local DarkModeSwitchButton = SettingsFrame:WaitForChild('DarkModeSwitch')

local Settings = {} 
Settings.DarkModeEnabled = LocalStore:RequestGet('DarkMode') -- Get the preset

local function ChangeDarkMode()
  -- Change the UI's color with Settings.DarkModeEnabled
end

DarkModeSwitchButton.MouseButton1Click:Connect(function()
  Settings.DarkModeEnabled = not Settings.DarkModeEnabled -- Change the settings
  LocalStore:RequestSet('DarkMode', Settings.DarkModeEnabled) -- Save the change
  ChangeDarkMode() -- Change the UI
end)

This is just a simple example of how to use it for Dark Mode saving so when you rejoin you don’t have to change it.

Updates

Current - First release, Simple saving and loading.

Future - Some more features, MemoryStore usage and performance improvance.

Conclusion

Git dump

Any bugs, improvements or comments feel free to reply below, I’m not exactly the most experienced scripter.

Thanks for using LocalStoreService,

Dandcx

4 Likes

Isn’t this mean exploiters can just access datastores? Because if this works client sided that means exploiters can just change or get any data from datastores and you really don’t want that in your game!

2 Likes

Read the description…

The entire point of this store is to save client-sided assets such as client-sided settings, ie (UI Colors, and KeyBinds)

But exploiters could change other user’s settings? Still sounds bad. Also there might be some security flaws and that could cause a disaster in a real game.

Edit: I would never, ever give any permission to DataStores for client.

This module uses basic RemoteEvent security. Exploiters don’t have access to everyone’s data. If you aren’t sure, just take a look at the source code

It’s tied to whoever sends the remote, so you can’t change any other users data but your own. The only security concern of mine after looking briefly at source code is there’s no blacklist/whitelist to what users can save so exploiters could flood their own DS/MS with tons of different keys.

I glanced through the code to find an answer to this question, and no, it’s not that bad. The code limits access by having client side indexes have “PlayerStore_” as a prefix.

However, there are a few red flags:


Why is 7544582036 required at the beginning of the script?

Why can’t we see what’s inside it?

Also, are there any measures in place to prevent the client from trying to store abnormally large chunks of data? I know Roblox is pretty generous with their datastore limits, but let’s not leave room to abuse that generosity.

A bit of a rushed module I’m sorry, I haven’t had many ways to test it.

Sorry I thought it was public it is now avalible, its just my custom datastore module.

I will try and make some more security advancements but theres only so much I could do.

Its an outdated project it just worked well with smaller projects

2 Likes