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

How to print multiple things?

When printing (or changing a Text value), it will not let you put multiple things in the parentheses.

For example:

nom = game.Players.Player1.Name 
print("hi there" nom)

The above script will not work. However, if you were to take out either the '"hi there"' or the 'nom', it would run fine. How do I make it so that it can print out multiple things in one line?

3 answers

✓ Accepted answer

Two strings can be joined into one string by concatenation.

The concatenation operator in Lua is .. (two dots).

For example,

print( 3 .. 2 )
-- 32
print("Root 2 is " .. math.sqrt(2))

As an aside, print will actually take multiple arguments:

print(3, 2)
-- 3	2

It inserts a tab ("\t") between them, which the ROBLOX output will render as a space (since it is HTML renderer).

1 comment

0

Equally good answer as the one accepted. Thanks for going in-depth and explaining it more!

nom = game.Players.Player1.Name 
print("hi there "..nom) --Put a space after 'hi there'. Otherwise it would say  "hi therePlayer1"

You use 2 dots.

Ex:

game.Players.PlayerAdded:connect(function(plr)
a=plr.Name
print("A new player ("..a..") has entered the server")
end)

You could do the same thing with a GUI you would just do

--Assuming its in the text
game.Players.PlayerAdded:connect(function(plr)
a=plr.Name
script.Parent.Text=("A new player ("..a..") has entered the server!")

2 comments

0

OK thanks! I knew there was a way to do it!

0

It is super handy, you can use it with any kind of String. 

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