-- создание таблицы лидеров

local function onPlayerJoin(player)
	-- создаём таблицу лидстата
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	-- добавление хранилища данных
	local stageStore = DataStore2("stage", player)

	-- создаём переменную этапа
	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Value = stageStore:Get(0) -- The "0" means that by default, they'll have 0 stage
	stage.Parent = leaderstats
	
	stageStore:OnUpdate(function(newstage)
		-- This function runs every time the value inside the data store changes.
		stage.Value = newstage
	end)
end
