Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

Are you new to scripting?

3 answers

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?

1 comment

0

Yep, how would I add ".Name" to the end?

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.

4 comments

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?

0

So, is (script.Parent.Text=script.Parent.Text ..".Name") what you are looking for?

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.

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?

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.

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.

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

Which returns the full name.

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

In which the returned value is the object

1 comment

0

I know i'm 4 years late but this is my way of even slightly, repaying you for answering my question

This discussion is preserved as it was. New answers, comments, and votes are closed.