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

Plugin_244111010.Script:81: bad argument #3 to 'Parent'?

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)

1 answer

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

2 comments

0

Well, then how would I make it where what they type in what part they want the decal to go into, the decal goes into it? (This is a plugin script)

1

Why have them type in the part instead of having them select the part? It would be much more convenient and easier to script.

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