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

Is there a way to write into scripts? Or edit scripts from other scripts?

Asked by 5 years ago
Edited 5 years ago

Question

Is there a way to write into scripts from other scripts?

For an example, a function that would write a string into a script

Example:

local SCRIPT = game.Workspace.ScriptToWriteIn

SCRIPT:Write("Bla bla bla") --Then it would write Bla bla bla into the script

Is this possible? if so how? I've checked a couple of times and no one asked this!

Thanks!

MIXGINGENGERINA10

2 answers

Log in to vote
1
Answered by
Aimarekin 345 Moderation Voter
5 years ago
Edited 5 years ago

No, that is not possible. Anyway, maybe you're interested in the loadstring() LUA function, which loads a string and converts it to a function you can execute.

[https://www.robloxdev.com/api-reference/property/ServerScriptService/LoadStringEnabled] [https://www.robloxdev.com/articles/Built-in-Functions-and-Variables/Lua#loadstring]

For loadstring() to work the LoadStringEnabled property of ServerScriptService must be true. Please mind using loadstring() is insecure.

0
In which way is it insecure? mixgingengerina10 223 — 5y
0
It is insecure beacuse with loadStringEnabled players can run arbitrary code, meaning they can execute whatever they want. Aimarekin 345 — 5y
0
Oh, thanks! mixgingengerina10 223 — 5y
1
Lua is not an acronym, and should not be spelt like one. So spell it Lua, and not "LUA". Just for the sake of readability and respect. User#19524 175 — 5y
0
In the example, is the user inputting code? hiimgoodpack 2009 — 5y
Ad
Log in to vote
0
Answered by
tantec 305 Moderation Voter
5 years ago

I suppose I have a way of writing into other scripts, but not editing the actual scripts. I haven't tested this out so I have no idea if it will work but give it a try! It works by using coroutines and sending them over in an event

****Script 1

lol = coroutine.create(function()
    -- your script here
    print("your nan is gonna kill me")
end)
game:GetService("ReplicatedFirst").ScriptWriteEvent:Fire(lol) -- firing the function

****Script 2

game:GetService("ReplicatedFirst").ScriptWriteEvent.Event:Connect(function(coroutine) -- receiving the event
    coroutine.resume(coroutine)
end)

For more information on coroutines go here

~tantec has a big lasting tan with a fran and he cant rhyme for his life

0
resume is not a valid member of Player in the Script no2 aka Script in workspace mixgingengerina10 223 — 5y
0
you're using a remote event there, im using a bindable event....... tantec 305 — 5y
0
use a bindable event for this tantec 305 — 5y

Answer this question