Hi, I made a time script that is supposed to save your data and add one to the leaderstat every second. It does that, until you rejoin with another player in your server. Here’s the script:
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("TimeSave")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local tim = Instance.new("IntValue")
tim.Name = "Time"
tim.Parent = leaderstats
tim.Value = ds1:GetAsync(plr.UserId) or 0
ds1:SetAsync(plr.UserId, tim.Value)
tim.Changed:Connect(function()
ds1:SetAsync(plr.UserId, tim.Value)
end)
while true do
wait(1)
tim.Value = tim.Value + 1
end
end)
It completely stops adding to the leaderstat when you rejoin, if you see the problem please let me know. Thanks.