Plugin Help, including classes, properties of an instance etc

Plugin Support

Heya devs, im trying to make a plugin that converts a TextLabel into a TextButton. To find the textlabel im using the Selection Service (using :Get()). When it comes round to trying to get a property, it comes out as nil. Here is sample code of what I have done:

local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Convert Class")
local newScriptButton = toolbar:CreateButton("Button - Label", "Converts a TextButton into a TextLabel", "rbxassetid://4458901886")
newScriptButton.ClickableWhenViewportHidden = true
function getProperties(inst : TextLabel)
    local AnchorPoint = inst.AnchorPoint
    local textbutton = Instance.new('TextButton')
    textbutton.AnchorPoint = AnchorPoint
end)


function onNewScriptButtonClicked()
	local selectedObjects = Selection:Get()
	local parent
	if #selectedObjects > 0 then
		parent = selectedObjects[1]
			getProperties(selectedObjects)
			print('attempting')
	else
		warn('please select a label to convert!')
	end
	ChangeHistoryService:SetWaypoint("Added new empty script")
end

newScriptButton.Click:Connect(onNewScriptButtonClicked)

This leads to an error thrown '‘Expecting Vector 2 got nil’, and every other property is nil as well.

4 Likes

the problem is here: getProperties(selectedObjects)
you are getting the properties of a table, not the “parent” object.

3 Likes

Tried this and worked! Thank you very much :grin:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.