Help With Datastore

Hello! I trying to make a Datastore for my game but the Roblox tutorial does not make sense to me. I have levels in my game on the player list but do not know how to make them save so they can join a different server without loosing them. Can someone please help explain!!!

1 Like

What this guy is saying isn’t true, you can ask anything relating to scripting here.

You can store data using the DataStore Service, here’s an example:

local dss = game:GetService("DataStoreService")
local lvlStore = dss:GetDataStore("Levels")
local plr --modify this to use the player you want, left it like this for reference

local playerID = plr.UserId
local level = 100 --example value, modify this to fit your script
 
--set data store key and value
local setSuccess, errorMessage = pcall(function() --this is to make sure the data gets stored
    lvlStore:SetAsync(playerID, level) --this sets the data to the level from before to the player
end)
if not setSuccess then
    warn(errorMessage)
end

If you have to work with player data, NEVER store data with usernames, as they will lose all progress when they change their name. Use the Player.UserId property of a Player object.

Mate, we got thousands of tutorials on youtube and devforum, no need to make a specific post on a topic you don’t understand.

I would also advise people not to spoon-feed him, it’s not how you learn.

Sorry I’m trying to get the basics from people who can explain it better and so I can go over it and see what is happening. That’s how I learn when I start new things.