First time join datastore doesnt work, but all the other work? [It's been 10 days and no one has answered]

  1. What do you want to achieve? Keep it simple and clear!
    I want to fix my datastore and my first time join script.
  2. What is the issue? Include screenshots / videos if possible!
    The issue is that for some weird reason it doesnt get saved AND doesnt get changed. Every other datastore works.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did but none of them had my problem.

Scripts:
The stats script:

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local coins = Instance.new("IntValue")
	coins.Name = "Coins"
	coins.Parent = leaderstats

	local cash = Instance.new("IntValue")
	cash.Name = "Cash"
	cash.Parent = leaderstats
	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Parent = leaderstats
	
	local rebirths = Instance.new("IntValue")
	rebirths.Name = "Rebirths"
	rebirths.Parent = leaderstats
	
	local joined = Instance.new("IntValue")
	joined.Name = "Joined"
	joined.Parent = leaderstats
end)

The save script:

local ds = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local save1 = plr.leaderstats.Coins
	local save2 = plr.leaderstats.Cash
	local save3 = plr.leaderstats.Level
	local save4 = plr.leaderstats.Rebirths
	local save5 = plr.leaderstats.Joined
	
	local GetSaved = ds:GetAsync(plrkey)
	if GetSaved then
		save1.Value = GetSaved[1]
		save2.Value = GetSaved[2]
		save3.Value = GetSaved[3]
		save4.Value = GetSaved[4]
		save5.Value = GetSaved[5]
	else
		local NumberForSaving = {save1.Value, save2.Value, save3.Value, save4.Value, save5.Value}
		ds:GetAsync(plrkey, NumberForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Coins.Value, plr.leaderstats.Cash.Value, plr.leaderstats.Level.Value, plr.leaderstats.Rebirths.Value, plr.leaderstats.Joined.Value})
end)

The first time join script:

local TeleportService = game:GetService("TeleportService")

local placeID_1 = 5739079494

game.Players.PlayerAdded:Connect(function(plr)
	repeat wait() until plr.leaderstats ~= nil
	if plr.leaderstats.Joined.Value == 2 then
		print("Welcome back~")
	elseif plr.leaderstats.Joined.Value == 0 then
		print("First timer~ Thanks for playing")
		plr.leaderstats.Joined.Value = 2
		wait(1)
		if plr then
			TeleportService:Teleport(placeID_1, plr)
		end
	else
		warn("ERROR: Couldn't check if the player joined for the first time or not. Kicking...")
		wait(3)
		plr:Kick("ERROR: Couldn't check if you joined for the first time or not. Please re-join!")
	end
end)

Also i tried manually changing the Joined value on the server, but it doesnt get saved, i also checked if it gets changed to 2 and it doesnt.

It’s been 10 days and no one has answered?? Someone please help! 58 views and yet no one has replied…

Okay i fixed it on my own all i did was add an wait in the join handler.

Can you tell me a bit more how you fixed it?

I just added wait(2) at the beginning of the script, literally says it in the solution.