Studio Play Test; allowing a set time delay before a "client" launches

Over the last few months I’ve been trying to do more server-based work and have found that pretty frequently that the “Play” feature in studio will launch the server and client within moments of eachother.

Typically this is not an issue.

However, the code I’m using on the server requires a brief moment to establish; sometimes its completed before the client loads in, sometimes the client has loaded in before the server can finish.

While launching a seperate Client/Server test environment circumvents this entirely; it’d be useful for iterative testing to be able to create an adjustable time delay between the server/client running in studio.

I also can’t find any documentation on the length of time between a server starting and clients connecting. Are there time-bounds to connections? (e.g; 2 seconds is the earliest a client can connect, attempting to connect for 30+ seconds is considered a faulty connection and is dropped)

EDIT:
I am running the server through a good deal of module scripts; I am circumventing Players being added by the following;

function PlayerAdded(player)
    print(player, "added")
end

function PlayerRemoval(player)
    print(player, "leaving")
end

Players.PlayerAdded:connect(PlayerAdded)

Players.PlayerRemoving:connect(PlayerRemoval)

for n, x in pairs(Players:GetPlayers()) do
    print(n, x, "already exists in-game????")
    PlayerAdded(x)
end

While this works in studio, it’s redundant in a live server.

8 Likes