Implementing Datastore in Points System Script

Ok so how to i implement datastore in a cash on kill script

This is my code if it will help

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Value = 0
	points.Parent = leaderstats
	
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(Died)
			local creator = Character.Humanoid:FindFirstChild("creator")
			local leaderstats = creator.Value:FindFirstChild("leaderstats")
			if creator ~= nil and creator.Value ~= nil then
				leaderstats.Points.Value = leaderstats.Points.Value + 10
			end
		end)
	end)
end)

You’re asking for a complete system to be made for you.

Does DataSore:SetAttribute store data?

NO, that changes the value of an attrubute. Which is like a custom property.

ok thanks man for the info!! I will try another method

i really need help. How do you implement datastore in the script above. i looked everywhere and even the link you sent. I still haven’t found the solution

This is the new script.

local DataSore = game:GetService("DataStoreService")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local points = Instance.new("IntValue")
	points.Name = "Points"
	points.Value = 0
	points.Parent = leaderstats
	
	player.CharacterAdded:Connect(function(Character)
		Character.Humanoid.Died:Connect(function(Died)
			local creator = Character.Humanoid:FindFirstChild("creator")
			local leaderstats = creator.Value:FindFirstChild("leaderstats")
			if creator ~= nil and creator.Value ~= nil then
				leaderstats.Points.Value = leaderstats.Points.Value + 10 or DataSore:SetAsync(points)
			end
		end)
	end)
end)

What should i add to make it save. (i really dont understand datastoreservice)