Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to transform a TextBox's text into a player's name?

I'm trying to make a game, where you can invite players to play together (the game has multiple places). When you write someone's name into the textbox, and press an Invite button, if the server contains that player, it appears on your screen, and you can press a Play button, to get on the same server (the TextBox is in the main place, what is a game menu, and you get teleported to an other place, where the real game is).

The explorer looks like this:

StarterGui Invite (ScreenGui) Frame Nam (TextBox) Invite (TextButton) Start (TextButton) Owner (TextLabel, the party owner's name) Party1 (TextLabel) Party2 (TextLabel) Party3 (TextLabel)

LocalScript inside the Invite:

local player = game.Players.LocalPlayer
local inv = script.Parent.Parent.Nam.Text
local invited = game.Players.inv

if invited then

	script.Parent.MouseButton1Click:Connect(function()
		if invited.PlayerGui.AcceptDeciline.Enabled == false then
	
			invited.PlayerGui.AcceptDeciline.Enabled = true
			invited.PlayerGui.AcceptDeciline.Frame.Accept.MouseButton1Click:Connect(function()
				invited.PlayerGui.AcceptDeciline.Enabled = true
				if script.Parent.Parent.Party1.Text == "" then
					
					script.Parent.Parent.Party1.Text = invited.name
					
				else
					
					if script.Parent.Parent.Party2.Text == "" then
						
						script.Parent.Parent.Party3.Text = invited.Name
					
					else
					
						if script.Parent.Parent.Party3.Text == "" then
							
							script.Parent.Parent.Party3.Text = invited.Name
					
						else
					
					
					
						end
					
					end
					
				end
			end)
		
		else script.Parent.Parent.Nam.Text = "Already In Party"
		
		end
	
	end)
else
	
	script.parent.Nam.Text = "Player Not Found"

end

LocalScript inside the Play:

local TeleportService = game:GetService("TeleportService")
local sologameID = 3315989953
local duogameID = 3327618291
local triogameID = 3327619773
local squadgameID = 3327620022

local par1 = script.Parent.Parent.Party1.Text
local par2 = script.Parent.Parent.Party2.Text
local par3 = script.Parent.Parent.Party3.Text
local party1 = game.Players.par1
local party2 = game.Players.par2
local party3 = game.Players.par3
local player = game.Players.LocalPlayer



script.Parent.MouseButton1Click:Connect(function()
		if script.Parent.Parent.Party1.Text == "" then
					
			wait(0.2)
			player.PlayerGui.Menu2.Frame:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Sine",0.5)
			wait(0.5)
			player.PlayerGui.Menu2.Enabled = false
			player.PlayerGui.Teleport.Enabled = true
			player.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
			TeleportService:Teleport(sologameID, player)
					
		else
					
			if script.Parent.Parent.Party2.Text == "" then
						
				wait(0.2)
				player.PlayerGui.Menu2.Frame:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Sine",0.5)
				wait(0.5)
				player.PlayerGui.Menu2.Enabled = false
				player.PlayerGui.Teleport.Enabled = true
				party1.PlayerGui.Teleport.Enabled = true
				player.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
				party1.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
				TeleportService:Teleport(duogameID, player,party1,party2,party3)		
					
			else
					
				if script.Parent.Parent.Party3.Text == "" then
							
					wait(0.2)
					player.PlayerGui.Menu2.Frame:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Sine",0.5)
					wait(0.5)
					player.PlayerGui.Menu2.Enabled = false
					player.PlayerGui.Teleport.Enabled = true
					party1.PlayerGui.Teleport.Enabled = true
					party2.PlayerGui.Teleport.Enabled = true
					player.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					party1.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					party2.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					TeleportService:Teleport(triogameID, player,party1,party2,party3)
					
				else
					
					wait(0.2)
					player.PlayerGui.Menu2.Frame:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Sine",0.5)
					wait(0.5)
					player.PlayerGui.Menu2.Enabled = false
					player.PlayerGui.Teleport.Enabled = true
					party1.PlayerGui.Teleport.Enabled = true
					party2.PlayerGui.Teleport.Enabled = true
					party3.PlayerGui.Teleport.Enabled = true
					player.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					party1.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					party2.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					party3.PlayerGui.Teleport.Frame:TweenPosition(UDim2.new(0,0,0,0), "In", "Sine",0.5)
					TeleportService:Teleport(squadgameID, player,party1,party2,party3)
					
				end
					
			end
					
		end
end)

2 answers

I'm not sure what you mean either, but you can do this:

local plr = game.Players.LocalPlayer
local plrname = plr.Character.Name

script.Parent.Text = plrname

2 comments

0

I want to make it like if the text that I wrote inside the TextBox is someone's name in the server, than...

0

https://www.roblox.com/games/3286873019/Nuntorrett This is the game. When you join and press PLAY you will see an Invite Player button. I want to make that work

This discussion is preserved as it was. New answers, comments, and votes are closed.