Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I see how long a player has been offline from the game for?

For example, if the player left the game and rejoined 8 hours later, it would show the player was gone for 8 hours. How can I do this?

1 comment

0

When the player leaves you can log the current time. Then when they rejoin you can see what time it is now compared to when they left.

1 answer

✓ Accepted answer

You would have to use a datastore, and use some time variable. (THERE WILL BE TWO SEPERATE SCRIPTS) (The script when the player joins)

game.Players.ChildAdded:connect(function(player)
local data=game:GetService("DataStoreService"):GetDataStore("Time")
if data:GetAsync(player.Name)==nil then
data:SetAsync(player.Name,os.time())
else
local s=os.time()-data:GetAsync(player.Name)
wait()
print(s)
--This script will print the number of seconds the player was gone.
end
end)

(The script when the player leaves, very simple)

game.Players.PlayerRemoving:connect(function(player)
local data=game:GetService("DataStoreService"):GetDataStore("Time")
data:SetAsync(player.Name,os.time())
end)

Demo place:

1 comment

0

Srry no demo place

This discussion is preserved as it was. New answers, comments, and votes are closed.