Please do not send images of code; instead, copy and paste your code into code blocks.
You do not have to create the leaderstats in both scripts.
Why are you doing DataStore:SetAsync() right after DataStore:GetAsync()?
You should not be saving the data every time the value is changed because data stores have a cooldown. There is a 6-second cooldown between write requests to the same key.
Why are you SetAsync right after you got the data. It should be like:
local data
local success, failure = pcall(function()
data = dataStore:GetAsync(plr.UserId)
end)
if data then
TimePlayed.Value = data.TimePlayed or 0
else error(“Failed to get data store. Code: “.. failure)
Then after that function, just make it so that whenever a second has passed for them, add 1 to their value. I recommend spawning a thread because if not, the increment would have to rely on the server which would increase the value for everyone in the server at the same time.