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

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

Asked by 4 years ago

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.

0
There's no method cause roblox has it disabled if you try those codes down there it will say lack of permission. VitroxVox 884 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

Easiest way:

local Script = Instance.new("Script",workspace)
local ScriptSource = "print("HAHA GET PRANKED IT ISNT ‘HELLO WORLD’ HAHAHA")"
Script.Source = ScriptSource
0
dude thats for plugins rookiecookie153 53 — 3y

Answer this question