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