Data Not Saving between Games?

I’m making a FNaF type of game on Roblox, so what I did is made the Nights as a place to the actual Main Game, which is the Main Menu.

However, in the Night Places (basically the placeId/game for the Nights located inside the actual MainGame, just a place to the actual game), there is a datastore script, which is used to saved Night Values. This script is in all the places of the Game, including the Main Game itself.

Script:

local dataStoreService = game:GetService("DataStoreService")
local nightDataStore = dataStoreService:GetDataStore("OWACNightDatas")

local players = game:GetService("Players")

local function setUp(player)
	local userId = player.UserId
	local key = "Player_" .. userId

	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"

	local night = Instance.new("IntValue",leaderstats)
	night.Name = "Night"

	local data = nightDataStore:GetAsync(key)

	night.Value = data or 1
end

local function save(player)
	local userId = player.UserId
	local key = "Player_" .. userId

	local leaderstats = player:FindFirstChild("leaderstats")

	if leaderstats then
		local nightValue = leaderstats.Night.Value
		nightDataStore:SetAsync(key,nightValue)
	end
end

players.PlayerAdded:Connect(setUp)
players.PlayerRemoving:Connect(save)

game:BindToClose(function()
	if #game.Players:GetPlayers() > 1 then
		for _,player in ipairs(players:GetPlayers()) do
			coroutine.wrap(save)(player)
		end
	end
end)

AFAIK (As far as I understand), if you put a datastore script in the main game, and the put the same exact one in the place of the game, it should have the data of the main game in the place. Why isn’t this working?

player["leaderstats"].Night.Value = 2 -- code that changes the value, then later teleports you back to main menu, this isn't being saved in the main menu, it's like it never happens

It sounds complicated, but can anyone help?

You could try saving before the player gets teleported.
Example:

saveData() -- Save the data
TeleportService:Teleport() -- Once the data is saved, it will teleport the player

I also recommend using UpdateAsync instead due to it being a safer method of saving.