Plugin help! I cant figure this out lol

So I am currently working on a plugin and I am having some problems.

First. I made saved my plugin as a local plugin right? anyhow. I have no idea now how to update the plugin. so every time I updated I cant see the actual update.

Anyhow the main coding part of it.

I am trying to make it so once you click on one of the Plugin buttons it adds a Vector3Value into the selected obj.

Except every time the script runs it always says it that there is either no object, or that its not a basepart. Even though the part is. Anyway to fix this? Heres my code

-- get the toolbar
local toolbar = plugin:CreateToolbar('Easy Size')


local button1 = toolbar:CreateButton(
	"Revert Size", -- text that appears below button
	'Activate', -- Text that appears if you hover the mouse on button
	"rbxassetid://8740888472" -- button Icon
)

local button2 = toolbar:CreateButton(
	"Add default size", -- text that appears below button
	'Activate', -- Text that appears if you hover the mouse on button
	"rbxassetid://8740888472" -- button Icon
)





local function getSelected()
	local selectedObj = nil
	
	if game:GetService('Selection') then
		selectedObj = game:GetService('Selection')
		
	end
	
	return selectedObj
end



button1.Click:Connect(function() -- revert size to origanal state.
	local selectedObj = getSelected()
	
	if selectedObj:IsA('BasePart') then 
		-- check if value is inside of the part
		if selectedObj:FindFirstChild('DefaultSize') then
			
		else
			warn('THIS PART DOES NOT HAVE THE DEFAULT SIZE VALUE YET. USE THE OTHER BUTTON TO CREATE ONE')
		end
	else
		warn('NO SELECTED OBJECT OR IS NOT A BASEPART')
	end
end)


button2.Click:Connect(function() -- create default size value
	local selectedObj = getSelected()
	print(selectedObj.Name)

	if selectedObj:IsA('BasePart') then 
		-- check if value is inside of the part, if not then create one
		if not selectedObj:FindFirstChild('DefaultSize') then
			local value = Instance.new('Vector3Value')
			value.Name = 'DefaultSize'
			value.Parent = selectedObj
			value.Value = selectedObj.Size
			
		else
			warn('DEFAULT VALUE IS ALREADY THERE. OVER RIDING IT')
			
		end
		
	else
		warn('NO SELECTED OBJECT OR IS NOT A BASEPART!') -- this always prints. The other code never runs
	end
end)
1 Like

game:GetService("Selection") Returns the selection service, you’ll need to get the current selected objects with game:GetService("Selection"):Get() then you can get a single object from the array with game:GetService("Selection"):Get()[1] .

Also idea pitch, try using game:GetService("ChangeHistoryService") to :SetWaypoint(waypoint_name) inside of the click event so that you can use CTRL + Z or CTRL + Y to undo/redo what you just did.

I looked at the thing. :Get is not a property of Selection. Idk Its not there for me

It is, dw. Here’s the documentation place for it as well.

Well in the mean-time. How do I update the plugin?

Normally when you’re saving it to your local plugins, just overwrite the plugin that you saved. This is how I update mine or test features before publishing to the market. If you renamed the file to another name, it’ll create another plugin rather than updating it which isn’t what you want.

How do I override the existing plugin? Im not very good with that kind of thing

Right click the script or folder you’re saving as a plugin

Then click Save as Local Plugin.

Then you’ll come across this:
image
Which shows you all your current local plugins, click the one you want to overwrite and press save. This should automatically update the current (singular) studio instance with the newer version of the plugin

Well it works now! Thanks!

Thanks yo!

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