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:
1 | script.Parent.Text.Name --didn't work, like I thought. |
2 |
3 | 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.
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?
You can set many properties with an equal sign. Just format it like this:
1 | game.Workspace.Part.Name = "hi" |
Of course, there are many read-only properties, but the name is modifiable.
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)
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)
1 | local str = loadstring ( 'return ' ..script.Parent.Text.. ":GetFullName()" ) |
Which returns the full name.
3)
1 | local str = loadstring ( 'return workspace:FindFirstChild(' ..script.Parent.Text.. ")" ) |
In which the returned value is the object