Concatenate intvalues and string in one TextLabel

I want to write 2 intValue and a String beetwen in a labelText.

textStats = script.Parent
local harvest = game.Players.LocalPlayer.folder.Harvest
local bag = game.Players.LocalPlayer.folder.Bag
while true do
	harvestString = tostring(harvest.Value)
	bagString = tostring(bag.Value)
	textStats.Text = harvestString, " / ", bagString ( Line underline in orange )
	print(harvestString, " / ", bagString)

In my textLabel only harvestString is write but in the output thanks to the print, it write correctly

I search solution everywhere but i find nothing.

What’s the error in the output, if there is any?

not had error just not write all the line

Use .. to concatenate strings: harvestString .. " / " .. bagString


Thanks you so much it’s working fine @bytechan

As an add-on:

  • .. needs to be used to separate actual strings (can not be a number, bool or data value. Use tostring(value) if you want to add a bool, number or data value to a string) when assigning strings to e.g. TextLabel.Text
  • , can be used to separate strings, bools, numbers and whatnot when using print() (separates and adds one space inbetween e.g. print("cow","milk") would print > cow milk )

Please mark the appropriate answer as the solution, so other DevForum users can find the answer if they encounter similar problem. Thanks!

For more advanced users, you can use string.format. Basic usage would look like this:

textStats.Text = string.format("%s / %s", harvestString, bagString)

Simply enter the text you’d like to display, with %s in place of your variables. You then specify the variables - in order - as the parameters.

This essentially allows you to create template strings. If you care about micro-optimisations, I believe string.format is also quicker than concatenation.

Read more about this on the Developer Hub: