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

How do I use string concatenation in Lua?

Asked by 10 years ago

Could someone tell me how i should use it and what its good for?

7 answers

Log in to vote
3
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

Concatenation is when you join together two strings. In lua, the concatenation operator is ..

Here's a quick example:

local message = "Merely" .. " has eaten a snowball."

The wiki has more information about concatenation.

Ad
Log in to vote
2
Answered by 10 years ago

String concatenation is used to combine two strings. The string concatenation "character" in Lua is .. (two periods).


print("Hi" .. " World!") x = "yo" y = "dog" print(x .. " " .. y) -- etc
Log in to vote
1
Answered by
Unclear 1776 Moderation Voter
10 years ago

Concatenation is the combination of two Strings into one. This can be useful when you're working with any type of Strings. A good example is referencing a set of objects following a rule (obj1, obj2, obj3...).

The concatenation symbol in Lua is .. (two periods), and combines the left string with the right string.

Here's an example...

print("h" .. "i")
Log in to vote
1
Answered by 10 years ago

Say if you have a player entered script. You do it like this...

game.Players.PlayerAdded:connect(function(plr)
msg = Instance.new("Message", Workspace)
msg.Text = "Say welcome to "...plr.Name
wait(2)
msg:Destroy()
end)

It basically allows strings and values to be added into something.

Log in to vote
0
Answered by
Minifig77 190
10 years ago

Concatenation is when you combine two strings. Basically, you put two dots in between two strings or other values that can be used in a string. Example:

Player = "Minifig77"
WinPercentage = 100

print("Player "..Player.." wins "..WinPercentage.."% of the time!"

In the output, you would see: Player Minifig77 wins 100% of the time!

Log in to vote
0
Answered by 8 years ago
Edited 7 years ago
game.Players.PlayerAdded:connect(function(plr)
msg = Instance.new("Name", Workspace)
msg.Text = "Welcome to "Game, plr.Name!
wait(2)
msg:Destroy()
end)

Log in to vote
0
Answered by 4 years ago

but then another man walks into the bar

Answer this question