Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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

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) Grenaderade 525 — 9y
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. Perci1 4988 — 9y
Ad

Answer this question