Why is the data not updating?

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.

1 Like

it’s likely this bottom line here where you say

profile.Gems.Value = data.Gems

when you saved the data, you saved it as data.gems yet when you’re loading, you’re capitalizing the “G”

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.