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

How does one add to user input to use for changing a parts name?

Asked by 7 years ago

I want to change the name of the part the player specifies in a textbox.

Say the user input tells me the part is at: game.Workspace.Part

What I want to do is add .Name at the end.

I've tried:

script.Parent.Text.Name --didn't work, like I thought.

ab = script.Parent.Text.. '.Name' --didn't work, however printing it resulted in the right path.

I'm not sure exactly what to do or how to do this.

0
Are you new to scripting? stefdejup1 0 — 7y

3 answers

Log in to vote
0
Answered by 7 years ago

Actually, if the player tells you its game.Workspace.Part, then that's exactly what it is - game.Workspace.Part.Name that you want to set. Correct?

0
Yep, how would I add ".Name" to the end? Kareem35 79 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

You can set many properties with an equal sign. Just format it like this:

game.Workspace.Part.Name = "hi"

Of course, there are many read-only properties, but the name is modifiable.

0
Doesn't seem like people are getting my point. The player enters into the textbox "game.Workspace.Part", using print(script.Parent.Text) will display "game.Workspace.Part", how can I take the input from the user as a path and add to it? Could I use loadstrings for this? Kareem35 79 — 7y
0
So, is (script.Parent.Text=script.Parent.Text ..".Name") what you are looking for? WingedHorizen201 124 — 7y
0
No, sorry was not clear. Not sure of a way to explain it where you guys can understand, consider it resolved if you want. Kareem35 79 — 7y
0
I think it is Ok to attempt to see if we can solve your problem. I think want you want is not to change the text, but to make it a separate string for later use, correct? WingedHorizen201 124 — 7y
Log in to vote
0
Answered by 3 years ago

I remember you from my other post a few years ago, just now, had to read the question 3 times to get what you were saying, I'm assuming you want either the full name, or the string path or the object.

1)

local str = loadstring('return '..script.Parent.Text..".Name")()

this will run the stuff in loadstring and return will give "str" the value of the loadstring

which means if script.Parent.Text was "workspace.Part" and I added .Name, it will be workspace.Part.Name, when returned str will be workspace.Part.Name.

2)

local str = loadstring('return '..script.Parent.Text..":GetFullName()")

Which returns the full name.

3)

local str = loadstring('return workspace:FindFirstChild('..script.Parent.Text..")")

In which the returned value is the object

0
I know i'm 4 years late but this is my way of even slightly, repaying you for answering my question greatneil80 2647 — 3y

Answer this question