I don’t usually use DataStores, but I was wondering how would you save somebody’s theme so each time they loaded into the main menu they would be greeted with a dark theme or light theme.
Could anybody explain how this works?
I don’t usually use DataStores, but I was wondering how would you save somebody’s theme so each time they loaded into the main menu they would be greeted with a dark theme or light theme.
Could anybody explain how this works?
On join, you would run code to fetch the theme:
local DSS = game:GetService("DataStoreService");
local ds = DSS:GetDataStore("PlayerMenuTheme");
local defaultTheme = "light";
local success, theme = pcall(function()
return ds:GetAsync(player.UserId) or defaultTheme;
end);
-- if not success then re-fetch or use defaultTheme.
Setting could be done on leave or on setting change:
local success = pcall(function()
-- theme == selected theme.
DSS:SetAsync(player.UserId, theme);
end);
-- if not success then honestly too bad it's not worth re-trying a theme save.