I Made A Points Leader stats ? How Do I Save it without breaking my code?

I Made A Points Leader stats ? How Do I Save it without breaking my code ?

Ive looked at tutorials but they just break the system

local Datastore = game:GetService("DataStoreService")
local ValData = Datastore:GetDataStore("ValData")

game.Players.PlayerAdded:Connect(function(plr)
	local data
	local s,e = pcall(function() data = ValData:GetAsync(plr.UserId) end)
	if s then
		if plr:FindFirstChild("leaderstats") ~= nil then
		end
	end
	if e then
		warn(e)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local data = {}
	local s,e = pcall(function() ValData:SetAsync(plr.UserId,data) end)
	if e then
		warn(e)
	end
end)

here this is the code for my game edit it as much as you like

Can you show me your code? I think you may have typed the code wrong

this is the code dude and no i didnt typed it wrong

I’m not asking you, I’m asking with @TheEternalDev