DataStore: How would I update a BoolValue saved in datastore?
Here is the script for creating the datastore value:
1 | game.Players.PlayerAdded:connect( function (player) |
2 | local BV = Instance.new( "BoolValue" ,player) |
4 | BV.Name = "Code1Redeemed" |
5 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "user" ..player.userId) |
6 | ds:SetAsync( "Code1" , BV.Value) |
Now, I'm trying to update the value when a player clicks a button:
1 | script.Parent.MouseButton 1 Down:connect( function () |
2 | local ds = game:GetService( "DataStoreService" ):GetDataStore( "user" ..player.userId) |
3 | local DataLoaded = ds:GetAsync( "Code1" ) |
4 | ds:IncrementAsync( "Code1" , true ) |
5 | print ( "Code1 sent to true" ) |
Unfortunately, It isn't working. I'm pretty sure I did it right, but I'm not sure. Any help appreciated.