local dataStore = game:GetService("DataStoreService"):GetDataStore("randommeusumtime") starterRolls = 0 game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr local points = Instance.new("IntValue") points.Name = "Time Spent" points.Value = dataStore:GetAsync(plr.UserId) points.Parent = leaderstats while true do wait(1) points.Value = points.Value + 1 end end) game:BindToClose(function(plr) dataStore:SetAsync(plr.UserId, plr.leaderstats["Time Spent"].Value) end)
Save script wont work. Very bogus since 4 others have fixed it, but save scripts hate me.
local ds = game:GetService("DataStoreService") local ds1 = ds:GetDataStore("randommeusumtime") starterRolls = 0 game.Players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder", player) folder.Name = "leaderstats" local points = Instance.new("IntValue", folder) points.Name = "Time Spent" points.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId, points.Value) end) game.Players.PlayerRemoving:Connect(function(player) local points = player.leaderstats["Time Spent"] ds1:SetAsync(player.UserId, points.Value) end) game.Players.PlayerAdded:Connect(function(player) local folder = player:WaitForChild("leaderstats") local points folder:WaitForChild("Time Spent") while true do wait(1) points.Value = points.Value +1 end end)
Try this. not sure whats not working.