Allow players to save and load settings using DataStore

I don’t completely understand what you’re saying, so bear with me.

I use ProfileService for most of my games, so that is what I’ll be using.

  • Default config: when they first join, a default car config is loaded for them
    In ProfileService, you can set a template for the player’s data if the player is brand new.
local ProfileTemplate = {
    Cars = {{
	name = "Car 1",
	nameKey = "Car1",
	description = "Your default car",
	colors = {
		["Back"] =  Color3.new(1, 0.25098, 1),
		["Right"] =  Color3.new(1, 0.25098, 1),
		["Left"] =  Color3.new(1, 0.25098, 1),
		["Top"] =  Color3.new(1, 0.25098, 1),
	}
}}
}
local ProfileStore = ProfileService.GetProfileStore(
    "PlayerData",
    ProfileTemplate
)
-- etc, etc...
  • Customizing: players can change attributes like color, name, description
    Using a RemoteFunction, you can do this!
    Client:
local Remote = game:GetService("ReplicatedService"):WaitForChild("CustomizeCar")
-- ... do whatever like clicking a button, etc.
Button.MouseButton1Click:Connect(function()
	Remote:InvokeServer("Car1", {
			["Back"] =  Color3.new(1, 1, 1),
			["Right"] =  Color3.new(1, 0, 1),
			["Left"] =  Color3.new(1, 1, 1),
			["Top"] =  Color3.new(1, 1, 1),
		})
end)

Server

local Data = require(PATH) --Custom path to a modulescript that retrieves the player's data
local Remote = game:GetService("ReplicatedService"):WaitForChild("CustomizeCar")

Remote.OnServerInvoke = function(Player, nameKey, colors)
	-- ... do checks like seeing if they own the car
	local Profile = Data:Get(Player)
	if not Profile then
		return false
	end
	local car
	for _, v in pairs(Profile.Data.Cars) do
		if v.nameKey == nameKey then
			car = v
		end
	end
	car.colors = colors
	return true
  • Saving: Players can save their car config
    You can follow a tutorial on this, like the ProfileService setup tutorial. It’s pretty simple.
  • Listing: Players can see a list of their saved configs
    You can do this by basically doing the same thing as you did by customizing.
    Client fires remotefunction to get all their cars → server returns every car the player owns → client takes that information and lists it in ui.
  • Loading: Players can load a config which will be applied to their car
    Same with saving.

I apologize if this wasn’t what you were looking for!

What do you mean by this?

2 Likes