So I am trying to make it so the player can rejoin when they request a rejoin. Keep in mind I want this to work via server not client. I tried following the instructions on the following link below but it didn’t help.
This was in the game, it’s a public game and it was not a VIP server.
The method you provided was correct, however, it requires a placeId, and I do not see anything about the last server they were on, so you would need to store it manually.
I encountered a similar issue and it was due to me using older teleport methods, you’d want to switch to teleportService:TeleportAsync and use a TeleportOptions to specify the target game.JobId (which would be the JobId of this server)
Here’s how I’d implement a rejoin command using TextChatService:
local players = game:GetService('Players')
local teleportService = game:GetService('TeleportService')
local textChatService = game:GetService('TextChatService')
local commands = textChatService:WaitForChild('TextChatCommands')
local rejoinCommand = Instance.new('TextChatCommand')
rejoinCommand.PrimaryAlias = '/rejoin'
rejoinCommand.Parent = commands
rejoinCommand.Triggered:Connect(function(source, text)
local userId = source.UserId
local player = players:GetPlayerByUserId(userId)
if not player then
return
end
local playersCount = #players:GetPlayers()
local teleportOptions
if playersCount > 1 then --[[ we check for the number of players to be greater than 1
because when we try joining this server, it will have
already been marked as shutting down (we will encounter
an inf. load), so we need to teleport them to a new server,
thus we want to not pass a TeleportOptions so we get the default
teleporting behaviour.
don't believe there's a way to get around the server shutdown behaviour ]]
teleportOptions = Instance.new('TeleportOptions')
teleportOptions.ServerInstanceId = game.JobId
end
teleportService:TeleportAsync(game.PlaceId, { player }, teleportOptions)
end)