Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Instance.new("Script", workspace)? How do you put code inside of it?

So I am trying to make it so that a script gets made via another script. And then I want to insert code inside of the new script. But I am not sure how to do so.

1 comment

0

There's no method cause roblox has it disabled if you try those codes down there it will say lack of permission.

2 answers

I don’t think there is a way to add a script into things and edit it entirely through a script (could be wrong), but even if there was there is a much more efficient way of going about it using clone:

https://developer.roblox.com/en-us/api-reference/function/Instance/Clone

To go about it using this method you would want to write the script and then put the script in ServerStorage or ReplicatedStorage depending on the use.


-- Then reference the script using a variable 

local ScriptToReplicate = game.ReplicatedStorage.ScriptName

-- Then clone it into the Workspace (or your desired location)

local ReplicatedScript = ScriptToReplicate:Clone()
-- Then reference the parent of the script using a variable 
ReplicatedScript.Parent = game.Workspace

As I said it doesn’t necessarily have to be cloned into Workspace, all you need to do to change the location is change game.Workspace to your chosen location.

Easiest way:

local Script = Instance.new("Script",workspace)
local ScriptSource = "print("HAHA GET PRANKED IT ISNT ‘HELLO WORLD’ HAHAHA")"
Script.Source = ScriptSource

1 comment

0

dude thats for plugins

This discussion is preserved as it was. New answers, comments, and votes are closed.