Source code can be taken directly from this place file: TimeAliveSystem.rbxl (32.0 KB)
https://www.roblox.com/games/6567524635
How to import source code
There are two Scripts, one SpawnLocation, and one BasePart. While holding down Ctrl or Cmd click each of these object in the Explorer. When they are all selected, use keyboard shortcut Ctrl + C or Cmd + C to copy. Then, with the Workspace selected in your own project, use keyboard shortcut Ctrl + Shift + V or Cmd + Shift + V to paste the objects into the Workspace. After everything’s successfully imported into your project, move each object into their correct locations:
- DataStore script gets placed into
ServerScriptService
- TimeScript script gets placed into
StarterPlayer > StarterCharacterScripts
- SpawnLocation and the BasePart named “Region” can remain in the Workspace.
After everything is imported and placed in their correct locations, make sure studio has access to API Services
. You can give this access by going to your game settings, click “Security” from the left sidebar, and then enable studio’s access to API Services
. This is important, because if disabled then the DataStore script will error while play-testing.
After that, you can publish your game to Roblox and test it out!
Important things to note
There are a few things you should note before testing:
- DataStores may not save your data while play-testing, but should work when leaving an actual server.
- Make sure your BasePart named “Region” is covering your SpawnLocation. The “Region” BasePart is responsible for checking if a player is standing on the spawn. So if a player walks inside of the region, the TimeScript script will know that the player is camping at the spawn.
- Resetting your character outside of the spawn will reset your current time score; but if you reset while within the spawn region, the current time score will not reset. If you wish to stop players from resetting altogether, you can simply disable the ability to reset your character.
Contact me
If you’re having any issues or have any questions, you can contact me here on the DevForum @P1X3L_K1NG
Thank you for using this “Time Alive” system that I programmed. Credit for the source code is not required, but is appreciated.