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

How can I project a variable on a GUI?

Asked by 9 years ago

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

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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!

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" DrCylonide 158 — 9y
0
As I said, I am assuming you have a way to get the player's name. Perci1 4988 — 9y
Ad

Answer this question