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

How can I project a variable on a GUI?

In my game, I have a building with a surface GUI on a brick showing the name of the building, but I would like to know how I can have a variable on the GUI.

My game example: "Cylocx's building" on a surface GUI. but when another player has their building: "Guest 1156's building"

Thank you in advance!

1 answer

You use concatenation.

I'm not sure what you have set up, so I'll assume you already have a way to get the player's name.

playername = "Bob"

GUI.Text = playername.."'s building" --Replace GUI with the correct hierarchy. 

What this does is basically combine the two strings. It does not have to be two strings though. You can use numbers as well.

local number = 10

print("I have "..number.." cookies")--It combines everything exactly, so make sure you have the spaces right!

--output: I have 10 cookies

Hope i helped!

2 comments

0

Hmm.. it didn't work.. I put the script into the part that has the SurfaceGUI. I did Parent.SurfaceGui.Textbox.Text = playername.."'s building"

0

As I said, I am assuming you have a way to get the player's name.

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