I'm making a plugin, at the end of the script I wanted to make it where it copies what you wrote in text boxes so it can make a decal go into a part... But the Parent part doesn't work, the output says I need an object. I don't know what that means.
I remember doing something like newdecal.Parent = "game." ..selection
, and it worked, but not this time somehow.
Can somebody help me?
local id = dId.Text local selection = pselect.Text local position = dpos.Text local newdecal = Instance.new("Decal") enter.MouseButton1Click:connect(function() newdecal.Texture = "" ..id newdecal.Parent = "game." ..selection newdecal.Face = "" ..position end)
The .Parent
property is not text -- it's an object. But selection
is text -- so you have to figure out which object and use that object.
If selection
is the name of a child in the, say, workspace
, you could use
newdecal.Parent = workspace:FindFirstChild( selection )
If it's the name of a descendant of the workspace, and it's name is unique, you can use the recursive search:
newdecal.Parent = workspace:FindFirstChild( selection, true )
Note that selection
is only being computed when this script first runs. If you want it to use the value when you clicked (you probably do) you have to get it in that event.
For getting arbitrary descendants, e.g. allowing text like "workspace.Model.SubModel.Part"
, see this question