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.