How to set a certain player points using DataStoreService

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to set a specific player certain points via DataStoreService using SetAsync() or UpdateAsync()

  1. What is the issue?

literally doesn’t work but instead breaks the leaderstats

Players.PlayerAdded(function(player)
	local ID = 66666666
	local data = player.leaderstats.Time
	
	local success, errormessage = pcall(function()
		PointsDataStorage:SetAsync(ID, data.Value == 55555)
	end)
end)

Its usually

		PointsDataStorage:SetAsync(Player.UserId, data.Value )

To answer your question yes. If you have the Key for the player you can change the data how ever you want in this case the key would be local ID = 66666666

actually it doesn’t break my leaderstats, I forgot to add :Connect after PlayersAdded but still doesnt work : /

Do you have your outputlog? and are there any errors?

not a single one, even when i try to print errormessage

did u make your leaderstats in a separate script?

Nope, they literally are in same script

But how is Time made?

PointsDataStorage:SetAsync(ID, data.Value == 55555)

Also you setting the number value within a :SetAynsc() you usually have what your storing as the second parameter like this

PointsDataStorage:SetAsync(ID, 55555)

Im not even sure what the outcome of doing data.Value == 55555 this as the second parameter would even do.

I have to go in a min but if you still need help ill return in around an hour

What i expected to see (just vaguely resembling this not 1 to 1)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	local LeaderStatsFolder = Instance.new("Folder")
		LeaderStatsFolder.Name = "leaderstats"	
		LeaderStatsFolder.Parent = Player
		
	local Time = Instance.new("NumberValue")
		Time.Name = "Time"  
		Time.Parent = LeaderStatsFolder
	
	local Key = Player.UserID
	local success, errormessage = pcall(function()
		PointsDataStorage:SetAsync(Key, Data being stored)
	end)

end)

This is just a vague example it works… just isn’t something you want to use without fixing ofc

My solution to this post was a working datastore that stores tables and uses leader stats if your interested Data store saving script only saving 1 of the 3 values - #14 by Extrenious