Script Pad: Run recursive code on models easily!

Script Pad (1.1)

NOTE: 1.1 brings in a few bug fixes. It also changed the default SelectionMode from EachInstance to EachDescendent. If you used this plugin before, make sure to check if your scripts still work.

This plugin allows you to run scripts on currently selected objects. This can be useful for utilities like modifying parts in a model to change their material based on their color. An example script is included. All scripts are saved.

How to Use

Upon clicking on the button in the plugin toolbar, this UI should come up:

image

Here is what each button does:

  • Add Selected Script: Add a script from the selection to the list of scripts
  • :pencil2:: Insert the script to the workspace
  • :wastebasket:: Delete the script from the list
  • Execute: Execute the script on the current selection

If you click the :pencil2: button on the default Reddify script, you’ll see a similar script in the workspace:

return {
	SelectionMode = "EachDescendent",
	Function = function(i: Instance)
		if i:IsA("BasePart") then
			i.BrickColor = BrickColor.Red()
		end
	end
}

Now let’s get a model to operate on. I will use Crossroads for this example:

image

Click the Execute button while selecting your model and everything should turn red!

image

The example script should be enough to know how to make your own script. You can make a module script that just returns a function:

return function(i: Instance)
    -- Operate on the instance here
end

Or make a table where you can assign settings to change how the function is called:

return {
    -- Put your settings here
    Function = function(i: Instance)
        -- ...
    end
}

Return table reference

string SelectionType
    Determines how the Function is called.

Possible values:

  • "Instances": Operate on a table of instances; write the function as function(i: {Instance}).
  • "EachInstance": Operate on one selected instance at a time; write the function as function(i: Instance).
  • "Descendents": Operate on a table of instances including their descendents; write the function as function(i: {Instance}).
  • "EachDescendent" (Default): Operate on one selected instance at a time including their descendents; write the function as function(i: Instance).
2 Likes

This is an awesome plugin :smiley: The UI looks slick and amazing and I will definitely be using this. Do you have a link where I can donate to you as well?