Can you edit the "content" of a local srcipt?

So i was wondering if you could edit the “content” of a local script on the Client. Becouse i wanted to try to make a “Script Editor”. I already searched but found nothing.

1 Like

I think you need to be more specific. If you wanted to change the contents of a Local Script, you are able to use FireServers to get the contents of a Server Script? That’s really the only thing you can do. Then again, I may be misreading the question. You can pass through parameters from the Server Script to the Local Script.

so i wanted to make a Editor were you can load a local script of your choosing and then you edit the local script and save the changes.

Ah, all I really know is that you’re able to pass information via FireServers/FireClients… sorry my guy.

No, players can not change the “content” of the script mid-game

If you are trying to make a Script Editing Plugin, then you can use the .Source Property of the script to get the contents inside of the script and edit it from there. .Source is available in Scripts, LocalScripts, and ModuleScripts. I have no real experience using this so you may to find guides around to help you understand how to use it and how to achieve what you’re trying to accomplish

(Oh and also, the .Source Property can only be used by a plugin, scripts and localscripts will error when attempting to use it. For more information, Dev Wiki’s page on the Source Property)

If u want to make a Script Editor u should manually make module script like make the Lua in Lua
like calling from module script raycast and stuff

I think you can use loadstring for that, assuming you are just getting the string inside a text box, but it can be very dangerous in some cases, as it can be used by exploiters for unwanted purposes.

“I think you can use loadstring” if that is possible, how would i do that.

Go to ServerScriptService and enable loadstring. You can only use it on the server for security purposes

-- example usage
local source = "for i= 1, 20 do print(i) end"
loadstring(source)() -- turns into code to compile
1 Like

Im not very experienced with it, but you can learn more in this post → How to use loadstrings? - #2 by Syclya

1 Like

When you are in-game, you cannot edit the scripts because they are already compiled. If you want to run scripts for the client, you can use a bytecode interpreter to run them since loadstring is disabled.

what is that, what does it do, how do i use it?

It’s basically something that simulates the way that the scripts run.

I haven’t tested it, but I found it a while ago

Example:

local loadstring = require(game.ReplicatedStorage.Loadstring)

loadstring("for i = 1, 5 do print(i) end")()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.