Saving progress

I’m Making this game where its all about progress and whos farthest. I don’t now how people will save there progress every time they play and leave. Right now when they leave the game they have to restart

4 Likes

You’ll want to take a look at DataStores. They will let you save and load data.

3 Likes

How would I save Its a obby kind of style game and I’m using teams for the stages.

1 Like

You could save the team’s name when the player leaves, and when the player rejoins add them to that team.

Is there a easier way I could save there progress?

If you had a leaderstat for stages I guess you could do that.

You would still need to save when the player leaves and load when the player joins.

Set the stages as a leaderstat and use DataStores as sleitnick said. If you need extra help just look up understanding DataStores on YouTube. Here’s a helpful video by AlvinBlox: https://www.youtube.com/watch?time_continue=10&v=DkYupSBUpes&feature=emb_logo

Also check this out: https://www.youtube.com/watch?v=vobF8wCyl6U

Thank You Ill check it Out and make sure it works for the style

1 Like

It’s a data store service.

How to retrieve?

local DataStoreService = game:GetService("DataStoreService")

How do I get data stores?

local MyDataStore = DataStoreService:GetDataStore("MyTestDataStore")

How do I save player data and load player data

Simply using GetAsync and SetAsync method.

GetAsync: MyDataStore:GetAsync(plr.UserId) – Retrieve player data.

Parameters: key, you need put key. If key is not in data store. It will return nil.

Return: Data, a value stored. (It’s from second parameters of SetAsync.)

SetAsync: MyDataStore:SetAsync(plr.UserId, 500) – Saving player data.

Parameters: key and value to save, you need key to create a data and put value to data and store it to data store.

I recommend you to use UpdateAsync since SetAsync only create data instead of updating value. So, that’s mean GetAsync will return inaccurate data. UpdateAsync update inside key value instead of creating new data.

How to use UpdateAsync?

            local newvalue = oldvalue + 5 -- Updating value by increasing value instead of creating data...
   if newvalue then
return newvalue -- Oldvalue become newvalue.
          else
return nil -- Cancels update.
   end
   end)```

--**Remember to wrap these data method in pcall.**

--**Instance, nil, etc (something that doesn't exist). can't be stored on datastore**
--**I suggest you to make identity data if player has data or not, if has. Load a instance else do nothing.**
--**Table, boolean, value, string, dictionary or etc. can be saved on datastore.**
--**If you want make leaderboard or rank leaderboard thing, you need use OrderedDataStore.**
--**If you play alone on roblox studio / roblox application, and you only have PlayerRemoving event that trigger saving value. If data doesn't save. You need put game:BindToClose function as it give 30 times to all server script to do task before times up.**
1 Like

It didnt work I tried his data store and checkpoint the check points wont work

Are there any errors in output?

No it just doesn’t spawn me on my checkpoints/spawns anymore

It puts me on a default team like neutral
local checkpoints = game.Workspace:WaitForChild(“Checkpoints”):GetChildren()

for i, checkpoint in pairs(checkpoints) do

checkpoint.TeamColor = game.Teams:FindFirstChild(checkpoint.Name)

end
theres the code he did for the check points

Aha! You used the wrong symbols around the :WaitForChild("Checkpoints") you should use " (which are quotation marks) instead of ’ (two apostrophes)

So this is the correct code:

local checkpoints = game.Workspace:WaitForChild("Checkpoint"):GetChildren()

for i, checkpoint in pairs(checkpoints) do
	
	checkpoint.TeamColor = game.Teams:FindFirstChild(checkpoint.Name)
end

it still puts me on Neutral team how do i fix that

Hmmm… Did you copy and paste the script I sent?

Yes i did it it keeps putting

me on the default team

Make sure the Stage1 team is set to AutoAssignable

Then delete the script that isn’t working and change the AllowTeamChangeOnTouch that is inside the checkpoint properties to true

thats what they always been on but i want to save there progress once they hit a checkpoint