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

How to put variable in text?

Asked by
iAviate 20
10 years ago

Hi, i'm trying to write a script that makes a TextBox's text say a message followed by a variable.

I've tried loads of different ways to write what seems like the same thing.

1local p = script.Parent.Parent.CarName
2 
3while true do
4    wait()
5    script.Parent.Text = (("Welcome into this ")..(p))
6end

also tried:

1local p = script.Parent.Parent.CarName
2 
3while true do
4    wait()
5    script.Parent.Text = "Welcome into this "..p
6end

and:

1local p = script.Parent.Parent.CarName
2 
3while true do
4    wait()
5    script.Parent.Text = ("Welcome into this "..p)
6end

Should be easy.... any help?

0
is there any outputs for any of them? And also, What is "CarName"? Is it literally something to get the name of a model, Or is it a TextBox of some sort? Uroxus 350 — 10y
0
"CarName" is a variable. iAviate 20 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

I believe your variable is incorrect. I do not know if CarName is something inside of your game, but assume you meant CarName , then you need to direct the script to the name of this so it may add it to your script.

1local p = script.Parent.Parent.CarName.Name
2 
3while true do
4    wait()
5    script.Parent.Text = "Welcome into this "..p
6end

If you actually mean Car and Name should have had a period in front, then:

1local p = script.Parent.Parent.Car.Name
2 
3while true do
4    wait()
5    script.Parent.Text = "Welcome into this "..p
6end

Future reference: You don't need a parenthesis around your string. just doing script.Parent.Text = "Welcome into this "..p will work. I believe parenthesis work as well, although I do not use them for what you're doing.

0
Make sure Hierarchy is correct. If this doesn't work, just comment. If this does, please +1 & Thumbs Up. alphawolvess 1784 — 10y
Ad

Answer this question