How to simulate Player -1 to exit and re-enter Studio's test server with 2 players?

I need to simulate 2 players in Studio:

  1. Start the server with 2 players
  2. Remove Player 1
  3. Player 1 needs to enter the game again (without restarting the server)

How to do that?

1 Like

Change it to 1 player and press Start again. It’ll keep the existing server and just add a new player. I can’t guarantee it’ll use the same UserId

1 Like

Would it not be possible for Player removal and joining events to have their functions decoupled (no longer anonymous) from the associated events.

This’ll allow you to “simulate” a Player being added or removed from a separate hook, without having to removing them.

Have you tested before?

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
	print(Player.UserId)
end)

Players.PlayerRemoving:Connect(function(Player)
	print(Player.UserId)
end)

I don’t quite understand, but if you mean just disconnecting PlayerAdded and PlayerRemoving, I don’t know how that will solve the problem.

I think they mean calling playerAdded / playerRemoving with the player as the argument, but not actually removing it, so after a delay in the script, do something like this:

PlayerRemoving(plr)
wait(1)
PlayerAdded(plr)
1 Like