Data not saving

I followed a tutorial to make a datastore and modified it, but it won’t work and the data won’t save. I don’t get an error either.
Code:

local DSS = game:GetService("DataStoreService")

local PlayerCash = DSS:GetDataStore("Cash")

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Folder = Instance.new("Folder")
		Folder.Name = "leaderstats"
		Folder.Parent = Player
		local Cash = Instance.new("IntValue")
		Cash.Name = "Coins"
		Cash.Parent = Player.leaderstats
		Cash.Value = PlayerCash:GetAsync(Player.UserId)
		if PlayerCash:GetAsync(Player.UserId, Cash.Value) == 0 then
			Cash.Value = 0
		end

		game.Players.PlayerRemoving:Connect(function(Player)
			PlayerCash:UpdateAsync(Player.UserId, Cash.Value)
		end)

		game:BindToClose(function()
			wait(1)
		end)
		
		game.Workspace.EndRace.Touched:Connect(function(character)
			local debounce = true
			if debounce then
				debounce = not debounce
				local player = game:GetService("Players"):GetPlayerFromCharacter(character.Parent)
				if player then
					wait(1)
					PlayerCash:UpdateAsync(player.UserId, Cash.Value)
					debounce = true
				end
			end
		end)
		
		while true do
			wait(60)
			PlayerCash:UpdateAsync(Player.UserId, Cash.Value)
		end
	end)
end)

You should check if the data exists.

if success and data then

Ok, I’ll try
character limit limit

It still says there’s no data in the player, even though I tested with my friends and the error disappeared
More info: the script also gives a custom warning saying unable to cast value to function.
I’ll send the game file:
Speedrunners (ALPHA).rbxl (86.0 KB)

The data isn’t a table, so you shouldn’t be using data[1]. (Try data)

But the table was defined in the saveData function.
I’ll try another script.

I changed the post because I used another script