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)