Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create saving slots?

I want to add savings slots to my game, but I don't know how I know that I need to use DataStore but... Is there any way to have saving slots

1 answer

✓ Accepted answer

Brief explanation.

You could prefix the data store keys with 'slot1_' followed by the user ID of the player.

Don't understand DataStores?

To create saving slots in a Roblox DataStore, you can use the SetAsync method of the DataStoreService class. Here's an example of how you might use it:

local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("MyDataStore")

local function saveData(player, data)
	local playerKey = tostring(player.UserId)
	myDataStore:SetAsync(playerKey, data)
end

local function loadData(player)
	local playerKey = tostring(player.UserId)
	local success, data = pcall(myDataStore.GetAsync, myDataStore, playerKey)
	if success then
		return data
	end
end

5 comments

0

Oh ok thanks!

0

Glad I could help. Could you please mark this as an answer to help others who may have the same question?

0

How do you do the big letters?

0

umm you didn't use "local success, data" correctly

0

it should be "local success, data = pcall(myDataStore.GetAsync, myDataStore, playerKey)"

This discussion is preserved as it was. New answers, comments, and votes are closed.