Hello,
I am trying to learn about Datastore2, as I heard it is rather convenient. However, I have run into an issue when using the :Set()
command for a boolean value.
I am using the following function to change the requested data. It seems to work correctly when I am using an integer, but when value
is a bool, it fails to update and gives the warning message.
I have also provided the function I use to initially setup the datastore
local defaultTable = {Wins=0, Points=0, Deaths=0, Kills=0, Infections=0,SWins=0,PWins=0,Coins=0,MusicEnabled=true)
DataStore2.Combine(MASTERKEY, "Wins","Kills","Deaths","Infections","PWins","SWins","Coins","MusicEnabled")
function module.ChangeData(player,key,value,increment)
local data = DataStore2(key, player)
if increment then
local success, err = pcall(function()
data:Increment(value)
end)
if success then print("Successfully incremented: "..key.." by "..value)
else warn("Could not increment Data")end
else
local success, err = pcall(function()
print(value)
data:Set(value)
end)
if success then print("Successfully updated: "..key.." to "..value)
else warn("Could not update Data..")end
end
end
function SetupData(player)
local sessionTable = DataStore2(MASTERKEY, player)
local sessionData = sessionTable:GetTable(defaultTable)
end
Can anyone help explain why this may be happening. I have just started experimenting with Datastore2 so chances are I am implementing it incorrectly.