Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to print multiple things?

Asked by
emite1000 335 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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).

0
Equally good answer as the one accepted. Thanks for going in-depth and explaining it more! emite1000 335 — 9y
Ad
Log in to vote
2
Answered by 9 years ago
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!")
0
OK thanks! I knew there was a way to do it! emite1000 335 — 9y
0
It is super handy, you can use it with any kind of String.  Tempestatem 884 — 9y
Log in to vote
-3
Answered by 9 years ago

print("hi there".. nom)

Answer this question