Firstly, I would also suggest putting all the code in one script, so its easier to manage and handle, unless you absolutely need to.
When you run the function connected with the PlayerRemoving event, you save the value of Time, yet you get the Value of gems when the player joins again. Could this be a possible mistake? You should try to save the gems Value if you want to retrieve it the next time the player joins the game.
Additionally, UpdateAsync accepts two parameters, the key it should update data in, and a function that actually updates the data (which it runs on its own). See here for more info. However, I think it makes little difference to use UpdateAsync in this case, and you could use SetAsync here. I made example code below to use as a guideline.
game.Players.PlayerRemoving:Connect(function(Player)
local leaderstats = Player.leaderstats
local Gems_Value = leaderstats.Gems.Value
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("TimeSave")
local success, err = pcall(function()
ds1:SetAsync(Player.UserId, Gems_Value)
end)
end)
@Syntheix UpdateAsync is actually more reliable of a saving method compared to SetAsync when use correctly. If you would like to learn more please read this great article.