How do I use data store on teams?

So i’m trying to make an obby with data store and i want to save this:

thispic
But the issue is I have no idea how to do it.

I have tried making a custom spawn script, but that’s hard for me.

Also i’m new to data store and i have just learned it recently.

You want to save what??

Just save data as you save data for every player regularly, you don’t need a Custom Spawn Script to save data for different teams.

Edit:

I think I understand what you mean now,
just try saving every player’s stage when they leave, and when they join, just set them to a team “Stage” concatenated with their stage number.

If you’re really knew to DataStores, I suggest inferring basic usage through posts scattered on the forum, here’s an outline regardless:

-- you can't save Instances through DataStoreService, unlike the old unreliable data persistence
-- you can only save strings, so even tables are formatted internally so you don't have to do it manually

 local DataStoreService = game:GetService("DataStoreService")
 local StageStore = DataStoreService:GetDataStore("StageStore")
 local data
 -- when the player joins,
 local success = pcall(function()
    data = StageStore:GetAsync(player.UserId)
 end)
 if not success then player:Kick("Data failed to load") end -- better to retry instead though
 data = data or 0 -- starting stage would be 0
 -- create a new IntValue named 'Stage' under a 'leaderstats' folder parented to the player
 -- set its value to data
 local teams = game:GetService("Teams")
 if not teams["Stage"..data] then
   -- create new team here with the name 'Stage'..data , which would mean you're creating a team with the certain name if it doesn't exist yet, you could just create x number of teams for x number of stages manually too
 end

 player.Team = teams["Stage"..data]  -- for data = 1, the team name would be Stage1

 -- when the player leaves,
 local folder = player.leaderstats
 StageStore:SetAsync(player.UserId, folder.Stage.Value)

The thing with saving data physically stored under a player is that there’s the edge case PlayerRemoving might fire after the instance was destroyed, disrupting the save operation.

It’s a good idea to have a representation of every player’s data in sub-folders under a container like game.ServerStorage, and for displaying the values, setting a Changed function to the values under the container to just change a value under a player’s leaderstats so the player can know what their value is when using leaderboards.

refer to the reply here about this: How to properly save player data in data stores upon server close - #14 by colbert2677

Yes, but how would I save data for different teams and when they rejoin they spawn at the right spawn?

I have don’t know how to tell the data store to save the players stage.

Like what type of value do i use?

You would use the player.Team value.

Yeah i can’t do this, i’ll try later.

I appreciate the help though. You gave me an idea of what to do but i’ll try to do it later.