Player Join System

I’m absolutely stuck on how to make a player join system, where player A would input player B’s username into a textbox and be teleported to their server. If anyone could point me in the general right direction on how to go about doing this, it would be appreciated.

I’ve searched the devfourm for any topics and I don’t know if it’s just my wording but if this has already been asked and answered a link to that would be cool.

EDIT:
I know what I need to gather, I need to gather player B’s userID to get their placeID and jobID, but I have no idea about how I could get it without player B being in player A’s game.

3 Likes

I think you have to use TeleportService

Yeah, I know that I need to use teleport service, but how would I go about getting the placeID and jobID for player B’s server? Once I get those, it would be quite simple to teleport player A to the correct place and server.

Use TeleportService:GetPlayerPlaceInstanceAsync(playerId) and TeleportService:TeleportToPlaceInstance()

I’m not sure how I would get the UserID of the player’s name entered into the text box, though.

Use the game.Players:GetUserIdFromNameAsync() function.

1 Like

I didnt clearly understand what you mean but in server systems, there is a host always so you dont have to care about that roblox already makes it for you

script.Parent.MouseButton1Click:Connect(function(plr) playerid = game.Players:GetUserIdFromNameAsync(script.Parent.Parent.TextBox.Text) local ci, _, endplaceid, endserverid = TS:GetPlayerPlaceInstanceAsync(playerid) TS:TeleportToPlaceInstance(endplaceid, endserverid, plr) end)

keeps telling me that the playerid is “unknown”,

I cleaned up the script a bit and I figured the playerid is unknown because it is not made as a variable and was just said without local. here is the fixed script:

local TS = game:GetService("TeleportService")
script.Parent.MouseButton1Click:Connect(function(plr) 
	local playerid = game.Players:GetUserIdFromNameAsync(script.Parent.Parent.TextBox.Text) 
	local ci, _, endplaceid, endserverid = TS:GetPlayerPlaceInstanceAsync(playerid) 
	TS:TeleportToPlaceInstance(endplaceid, endserverid, plr) 
end)
1 Like

First off, my apologies for not formatting my code correctly.
However, it still is returning that the playerID is unknown. I’ve tried it both in studio and in the roblox client, and yet it still doesn’t work.

I think this is because the Text in a textbox is local and not server. (sorry for not responding sooner I was doing something)

4 Likes

I feel really stupid for not realising that this could be the case. Thank you for replying.

I’ll use a remote event to give the server script the playerID and I’ll update the thread from there.

Just for clarification for anyone stumbling upon this thread:

  1. Get the player’s ID from the text box on the local side.
  2. Fire a remote event which tells the server the player’s ID.
  3. Using the player id and GetPlayerPlaceInstanceAsync to get the jobID and gameID.
  4. Teleport using TeleportToPlaceInstance.

Yes, this did indeed work. Thank you.

5 Likes