If you’re trying to save your player’s data, you should be using SetAsync, not UpdateAsync. UpdateAsync is used to compare your changed values, not save them into the datastore.
What you are trying to achieve is still a gray area to me, but one thing I can tell you is that if you are 100% certain that you are only going to have the values 1 and 0 for a given data, you shouldn’t use operations like + or - because let’s say someone were to fire an event to the server more than once in the matter of a second, the value will keep decreasing and will eventually go below 0 as a result.
I’ve tried using SetAsync but it wont set the Value after I changed it, it prints that its changed but when I look back at my stats in the explorer it didn’t
Are you trying to change the stat in the leaderboard too? Saving to a datstore won’t automatically change the leaderstat. You would have to manually change that as well.
The Datastore and the leaderboard stat itself are not related. Say that you have a stat named “Points” on the leaderboard next to a player’s name. If you change a Datastore value for a player also named “Points” it won’t change the leaderboard just because they happen to have the same name. If you want to change the value on the leaderboard, you may want to check out this article about Leaderstats.
Specifically to change a stat on the leaderboard you will have to find the Value object and change its value. For example, you have a player named “xipped”, who has a stat named “Points”. To change xipped’s points on the leaderboard, you would first want to access the player xipped, from game.Players. Then you want to find xipped’s leaderstats folder. game.Players.xipped.leaderstats. Then you would want to access the “Points” object in leaderstats. game.Players.xipped.leaderstats.Points. And to make it easier, let us set a reference. So the final reference might look like
local pts = game.Players.xipped.leaderstats.Points
And to increment this we would access its value:
pts.Value = pts.Value + 1
This is all assuming that you have already set up the leaderstats folder for the player. I highly suggest you look at the linked article. My main point is that just changing the datastore won’t change a value on the leaderboard, and vice versa. You have to manually change both.
This isn’t my goal, my goal is actually to change the data of an offline player, like you can kick them out of your party without them being in your server and there is no way I can access the folder on it.
Changing the data of an offline player is the same as changing the data of an online one. The problem is getting the player’s ID to change the key to the datastore. There is no difference in actually setting the value.
Okay, so I made a numbervalue Instance and set the Value as the member value I got from the player. changed the NumberValue Instance and set it again, do you think it would work?