Make a script while playing a game

hello! im trying to make a ui with text box and save button that you can write some code and when you save it makes a script and adds it to the script code how can i do it?


Every script has a .Source property, but it’s only accessible in studio, you can’t access it at runtime or in a real game.

This is impossible, and probably not very efficient. Instead, use DataStoreService for saving.

1 Like

how do i use datastoreservice to save the code and put it in a script

On ServerScriptService enable loadstring, loadstring() is a function which you can insert a string to and it’ll output a function. However be careful doing so as it makes your game vunerable to exploiters.

I recommend not doing this at all, it will make your game very vulnerable.

I’d suggest doing it only if you are wanting to use it to give an average player access to run scripts, which in certain games like require script fighting games, is the goal.

You can’t change code at run time as I already stated, but you can use DataStoreService:

local DSS = game:GetService("DataStoreService")
local scriptStore = DSS:GetDataStore("Script")

local suc, err = pcall(function()
    scriptStore:SetAsync(player.UserId, *your script data here*)

if not suc then
    print("something went wrong...")

Using this service, you can save data to persist between sessions. When the player comes back you can load the string back, but running the script using loadstring(), and giving people server permission to run code, I don’t recommend.

If you’re looking to run code, you should dumb it down to only the client.

the goal is that the players can make scripts(doesn’t matter what kind) that you can execute and it will run the code

I’ve warned you, but yes, you can use loadstring to run code:

See here for more information.

why warn me what is the problem with this?

Because it’s very unsafe, if you let people run code on the server, they can easily do game breaking scripts that will ruin your game. Or even insert backdoors or malicious models into your game, that can get your game and even you banned.

but cant i put limitation so there will not be a backdoor or something?

and i have another question how do i make it so when the player saved the code it will use the loadstring to execute it?

bro almost are exploiter tools are dead

synapse x DEAD
krnl DEAD
fluxus DEAD
cheat engine works but u cant execute scripts
CE executors got patched

That doesn’t mean it’s not possible to exploit anymore. There are still probably some executors out there that work.

yeah, but like 95% of exploiters are gone, even emulators will get a anitcheat soon
(only the 5% will be a lil problem)

i dont think people are really going to cheat on this game

That still doesn’t mean it’s not a problem and it’s okay to just be lackadaisical with your permission and safety.

You can go ahead and use loadstring() functionality on your game. Make sure to do the research. I don’t want a fellow developer getting in trouble :frowning:

and den_vers i dont know but how to use the loadstring to make it execute