But I want to make it when the player is either kicked or banned their “Offenses” go up by 1 but I’m not sure how to add Stuff inside a datastore any ideas? I’ll do the rest such as detecting the number of offenses and if it’s like 5 or something they get banned. Much appreciated if you do help!
Do you not cache a player’s data in the current session with a table anywhere? Are you directly writing to a player’s data in a DataStore and that’s where you need help? UpdateAsync allows you the opportunity to transform data so that should be what you’re using if you don’t have an in-session cache.
Store:UpdateAsync(player_key, function(savedData, keyInfo)
local userIds = keyInfo:GetUserIds()
local metadata = keyInfo:GetMetadata()
savedData.Offenses += 1
return savedData, userIds, metadata
end)
No, I don’t when I first made this I guess I had no reason to, should I be doing this and how would I store data in a table if the player isn’t in the game (You can use UserIds to ban people).
If the player isn’t present in the game you shouldn’t need to modify their data unless you need to retroactively change their data manually.
What you can do is call “:GetAsync()” with their key. With the retrieved data you can then modify it as you desire and then call :“SetAsync()” with the same key in order to override their existing data with the modified version. This can also be achieved with “:UpdateAsync()” as has been suggested.