Teleport an entire server using os.time

local GameId = "123456789" 
local EventTP = 123456789
local Player = game.Players:GetPlayers()
local currentTime = os.time() 

if currentTime == EventTP then
	
end

I’m attempting to teleport the whole server at a certain time, for my live event.

I have forgotten how to use the TeleportService and I am currently braindead.

I would really appreciate some help finishing the script and correcting any errors please. :smiley:

Thanks!

2 Likes

For doing that, you’d want to do something like this:

local GameId = 123456789 -- PlaceId
local EventTP = os.time({
	year = 2023,
	month = 7,
	day = 14,
	Hour = 16,
	Minute = 0,
	Second = 0,
})
local CurrentTime = os.time()

if CurrentTime < EventTP then
	task.wait(EventTP-CurrentTime)
	game:GetService('TeleportService'):TeleportPartyAsync(GameId,game.Players:GetPlayers())
else
	local players = game.Players:GetPlayers()
	
	game:GetService('TeleportService'):TeleportPartyAsync(GameId,players)
end
1 Like

If this works you’ll be an absolute legend for life.

This works, but seeing as you’re working with time, your wait logic is quite inefficient. Upon the server loading, we can check to assure we haven’t passed the live event time yet, and then we can simply wait the difference:

local GameId = 123456789 -- PlaceId
local EventTP = 123456789 -- Timestamp of when you want player's to TP to game
local currentTime = os.time()

if currentTime < EventTP then
	task.wait(EventTP - currentTime)
	game:GetService('TeleportService'):TeleportPartyAsync(GameId, game:GetService("Players"):GetPlayers())
end
--You could teleport them instantly if it's past the time, or you could check how far past you are and decide if you still want to teleport them, etc.

This could result in some servers being teleported at slightly different times depending on server lag, but it should be negligible.

Yeah, I suppose just waiting until rather than doing a while loop would be more efficient. Good catch.

Also, if you wanted to be able to more easily set the timestamp of EventTP, you could do this:

local EventTP = os.time({
	year = 2023,
	month = 7,
	day = 14,
	Hour = 16,
	Minute = 0,
	Second = 0,
})

im actually considering adding a live event to my game, is there any way to successfully migrate to an update without shutting down/leaving the server?
[ik its off topic but since last posts was 11 mins ago i hope u guys will reply]

if you publish a new update to a game, the old servers are still running the old build of the game and you need to either shut down all servers, or wait for all the servers end by players leaving the game and joining on new servers with the newest build of the game

Maybe a soft shutdown? The servers detect they’re being shutdown, teleport the players to another place and cover the screen with UI, then 20 seconds later teleport them back?

1 Like

yeah seen that used alot… ill prob do that but i was wondering if it was possible to just reset the servers… oh well

p.s. if u wanna alpha-test my game Dm me and visit this

1 Like