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
9 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.

local p = script.Parent.Parent.CarName

while true do
    wait()
    script.Parent.Text = (("Welcome into this ")..(p))
end

also tried:

local p = script.Parent.Parent.CarName

while true do
    wait()
    script.Parent.Text = "Welcome into this "..p
end

and:

local p = script.Parent.Parent.CarName

while true do
    wait()
    script.Parent.Text = ("Welcome into this "..p)
end

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 — 9y
0
"CarName" is a variable. iAviate 20 — 9y

1 answer

Log in to vote
0
Answered by 9 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.

local p = script.Parent.Parent.CarName.Name

while true do
    wait()
    script.Parent.Text = "Welcome into this "..p
end

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

local p = script.Parent.Parent.Car.Name

while true do
    wait()
    script.Parent.Text = "Welcome into this "..p
end

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 — 9y
Ad

Answer this question