I am trying to script something where when characters are entered into a textbox on a screengui and a button is pressed, then the name of parent's parent of the initial script will be changed to that of the inputted text in the screengui textbox.
script.Parent.Parent.Parent.Parent.Parent.VehicleSeat.TrainGui.Main.Buttons.Delayed.MouseButton1Click:connect(function() script.Parent.Parent.Name = script.Parent.Parent.Parent.Parent.Parent.VehicleSeat.TrainGui.Main.CBTC.One.Text print(script.Parent.Parent.Parent.Parent.Parent.VehicleSeat.TrainGui.Main.CBTC.One.Text) end)
When I put in text into the textbox, it does not change the parent's name.
I received the following outputs:
02:26:23.782 - TrainGui is not a valid member of VehicleSeat
02:26:23.783 - Script 'Workspace.R160 Franklin Av Shuttle.Train.First.Bogey1.DestGlider.CBTC', Line 2
What is the issue?
Note: Line 2 in the output is referring to the Lua provided above.
1 - Never try to change names of the core elements,
Consider this
You have one element called "A" and another element called "B" ~ No use of it lol
So, whenever you try to change the name of the element called A to B's name(that is "B") you will try to point out the elements and change their name like this
A.Name = B.Name
Ok, that was good, you changed the name... But what if I changed the text in the text box and try that again? your code is not reusable, meaning it will only work once.
The next time it tries to find the element, your "A" element is changed to "B", so the code breaks
Hope that helps idk i just drunk