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

It is possible to tell if server is new?

How do you tell if the server is new. New as in the server has not be played before as i want to run different codes for the first player. Thanks

1 comment

0

Give us more information on what you want to achieve.

3 answers

whenever a server starts, you get the EPOCH seconds via os.time() and store them somewhere..

whenever you want to know how old the server is you could do os.time() - storedEPOCHseconds

another thing would be to use a loop that constantly adds 1 to a value after one 1 seond, but that will require constant memory allocation, and depressing performance of your game with each second that passes,

so i personally prefer the first example, and here is how you could implement it...

you could use a module like this:

-in a module script..

local module = {};
local startingTime = os.time();

function module.getServerAge()
	return (os.time() - startingTime)
end

--in a script

local mod = require("serverAgeModule")
print(mod.getServerAge())

but will put an emphasis on requiring the module immediately in another script

or put the starting EPOCH value in an IntValue

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