DataStore2 doesn't save

I use DataStore2 to save a value and I worked on it for several days. The problem that happened was that it saved in Studio, but not on the normal ROBLOX program. Why is this happening?

script:

local DataStore2 = require(game.ReplicatedStorage.DataStore2)

DataStore2.Combine("wowness", "PersonalityTrait")

local defaultTrait = ""

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

    local dataTrait = DataStore2("PersonalityTrait", player)

	local PersonalityTrait = Instance.new("StringValue", leaderstats);PersonalityTrait.Name = "PersonalityTrait"
	
	PersonalityTrait.Value = dataTrait:Get()
	
	game.Players.PlayerRemoving:Connect(function()
	   dataTrait:Set(PersonalityTrait.Value)
	   end)
	
	while wait(200) do
		dataTrait:Set(PersonalityTrait.Value)
	end
end

game.Players.PlayerAdded:Connect(playerAdded)
for _,player in pairs(game.Players:GetPlayers()) do
   spawn(function() playerAdded(player) end)
end

well, 1st mistake I see is that you continue adding folders to each player which probably gets in the way of saving their actual data. here is where the problem is:

game.Players.PlayerAdded:Connect(playerAdded)
for _,player in pairs(game.Players:GetPlayers()) do
   spawn(function() playerAdded(player) end)
end

instead of getting all the players, only get the player that joined. to fix this, simply remove the

 for _,player in pairs() do

line and change the value of what join (you have it as “playerAdded”) to player. Then change the function line to this.

playerAdded(player)

Okay, I changed it to what you said but nothing really changed, but I hope it fixed some issues. The DataStore2 still doesn’t save the player’s data (string value).