So I have a script that saves data but I noticed it is not updating.
Why is this? There are no errors so I have no idea why.
-- load the profile
local function loadProfile(player)
local tag = player.UserId..'_profile'
local profile = player.Profile
-- data variable
local data
-- get the data
local succes,errorMessage = pcall(function()
data = profileStore:GetAsync(tag)
end)
-- tell if we got the data
if succes then
print('Succes')
if data == nil then -- they are new
print('Player has no data')
profile.Gems.Value = mod.DefaultValues.gems -- set the default gems
else -- they have data
print(data)
print('Player does have data')
profile.Gems.Value = data.Gems
end
else -- there is an error
print('There was an error')
errorFunction(player)
warn(errorMessage)
end
end
save data
local function saveData(player)
local tag = player.UserId..'_profile'
local profile = player.Profile
-- lets detect if there was no error
if not player:FindFirstChild('Failed') then
print('No error, updating data')
local currentData = {
gems = profile.Gems.Value,
}
profileStore:UpdateAsync(tag, function(pastData)
print(pastData)
return currentData
end)
else
print('Error. We are not going to update there data')
end
end
Any who its not saving the data. Either that or it is not loading it.
I think its not saving though.