Is there a way to make textbox as an in game editor and can run basic script like we have two frames , one frame contain with textbox, and another frame contain for output. So when the player write in textbox like
local str = “Yes”
print(str)
It will generate a textlabel with print str, but the code came from textbox. Because I saw couple forum/game that has script/code editor inside that can run script that you write using textbox.
Theoretically, you could use loadstring() and LogService to do so. You could get the loadstring, then get the log history. After that you could call the loadstring and then every time LogService.MessageOut is fired, that would be from the loadstring, and when it stops, you could put those into the output.
Like @eaterofananas8 said: You could use loadstring() to run the Code. But that’s not the best idea as enabling this would give exploiters alot of power - Technically not alot but would also let them do more bad stuff than they can already do.
If you’re looking towards a very amazing and reliable command bar, You could try using Cmdr since it’s the best Command Bar to be implemented into games so far and it also comes with alot of things, So it’s pretty much very customizable.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local frame = Instance.new("Frame")
frame.Name = "Test"
frame.Parent = Player.PlayerGui:FindFirstChild("TestGui")
That’s not a code runner but a Command Bar. It allows you to execute certain pieces of code such as Commands to teleport Players, Give them a certain amount of money and in-between alot of more things that yourself should implement.
By the way, Using code executors in your game can lead to your account possibly being banned, There’s alot of people that already got their accounts punished for doing so. If you want to create a code executor, Then do it, But don’t get surprised if you get a warning.
If you want to allow players to be able to run any code in-game (like @MeCrunchAstroX said, can get your account in trouble), so be it.
But if you only want them to run code like printing and such, then I would suggest filtering out any lines that have any reference to the objects in game (such as Instance.new(), script, game, workspace, etc).
Ah maybe that’s a good idea, i mean only for print is no problem right? and how to make if in the code they have print, it will be output to my output GUI same like how Command Bar on roblox studio do when you have print on your script.