Here is the script for creating the datastore value:
game.Players.PlayerAdded:connect(function(player) local BV = Instance.new("BoolValue",player) BV.Value = false BV.Name = "Code1Redeemed" local ds = game:GetService("DataStoreService"):GetDataStore("user"..player.userId) ds:SetAsync("Code1", BV.Value) end)
Now, I'm trying to update the value when a player clicks a button:
script.Parent.MouseButton1Down:connect(function() local ds = game:GetService("DataStoreService"):GetDataStore("user"..player.userId) local DataLoaded = ds:GetAsync("Code1") ds:IncrementAsync("Code1", true) print("Code1 sent to true") end)
Unfortunately, It isn't working. I'm pretty sure I did it right, but I'm not sure. Any help appreciated.
Instead of using IncrementAsync, you should be using SetAsync:
script.Parent.MouseButton1Down:connect(function() local ds = game:GetService("DataStoreService"):GetDataStore("user"..player.userId) local DataLoaded = ds:GetAsync("Code1") ds:SetAsync("Code1", true) print("Code1 sent to true") end)
For more info:
http://wiki.roblox.com/index.php?title=API:Class/GlobalDataStore/SetAsync