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

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

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

✓ Accepted answer

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.

5 comments

0

In which way is it insecure?

0

It is insecure beacuse with loadStringEnabled players can run arbitrary code, meaning they can execute whatever they want.

0

Oh, thanks!

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.

0

In the example, is the user inputting code?

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

3 comments

0

resume is not a valid member of Player in the Script no2 aka Script in workspace

0

you're using a remote event there, im using a bindable event.......

0

use a bindable event for this

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