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

Is it possible to change roblox default script code of print("Hello World")?

Asked by
Gunt_r 31
4 years ago
Edited 4 years ago

I want to change the default print("Hello World") to a require statement so i dont have to bother copy and pasting the require statement every time i create a new script.

Instead of print("Hello World"), i want roblox to initialize with the line local inspect = require(script.Parent.inspect)

Is this possible?

0
Maybe try forking it..? I'm not sure what you mean. niroqeo 123 — 4y
0
I reworded it so it's easier to understand now. should have put more effort into legibility in the first place sorry. Gunt_r 31 — 4y
0
I hope this receives an answer that will override default functionality. mdjsword 15 — 3y

1 answer

Log in to vote
0
Answered by
Sulu710 142
4 years ago

In order to do this you'll need a plugin. I don't know much about plugins, but this should do what you want. Put this inside a regular script in server script service:

local ChangeHistoryService = game:GetService("ChangeHistoryService") -- Just makes sure you can undo anything you do with this plugin

local toolbar = plugin:CreateToolbar("Custom Script Tools") -- Creates a button on the plugin toolbar that will add the script when pushed

local newScriptButton = toolbar:CreateButton("Create Require Script", "Create a script without print(HelloWorld!)", "rbxassetid://4458901886") -- Idk exactly what these do, but they basically just change the title and description of the plugin, try to play around with them (do not change the third parameter with the rbxassetid, and the title and description must be in quotes)

local function onNewScriptButtonClicked()
    local newScript = Instance.new("Script")
    newScript.Source = "local inspect = require(script.Parent.inspect)"  -- put what you want to be written inside the script instead of "print("HelloWorld!")" here in quotes
    newScript.Parent = game:GetService("ServerScriptService") -- This will add the new script into the server script service. If you want it to be parented to something else, then change this to the instance you want the script to be parented to. Server script service is recommended though because it's the best place for scripts and it'll make it easy to find. Also note if the parent instance gets moved or gets it's named changed, this won't work
    ChangeHistoryService:SetWaypoint("Added new empty script") -- Also makes sure you can undo the creation of the script 
end
newScriptButton.Click:Connect(onNewScriptButtonClicked) -- Will create the new script with all your specifications when you push the button in the plugin toolbar

When you've finished writing the script, right click the script in the explorer and select Save as Local Plugin. This will save the plugin to your computer, and the button should appear in the plugins tab of studio. If it doesn't, push the "Plugins Folder" button on the left side of the plugins tab and upload the plugin from your computer. Also, when you're making your script, "plugin" might get underlined as an error, but this is normal it will still work perfectly fine.

Plugins can get pretty complicated, so if you want something more than this, I would recommend checking out some plugin-making tutorials, because this is about the limit of my plugin knowledge. I hope this works!

Ad

Answer this question