Hi, So I tried using the loadstring function and it works pretty well and Im using it to create a Lua Executor game.
What I’m getting errors about is, It sometimes returns this response in the console, I don’t really know whats causing it.
The error response: PlayerGui.ScriptExecutor.MainFrame.ClientExecuteButton.LocalScript:21: attempt to call a nil value
So basically, When I want to execute a code I type it off in this Box and execute it, and later I tried using a function in the code but It gave that response.
Heres how the executor looks.
So the green Play button is server-side execute, and the blue one is client-side.
This is my code I tried in that executor.
local function foo()
print('Hi')
end
foo()
Green PB Script →
local scriptBoxes = script.Parent.Parent.Parent.ScriptDisplay.ScriptBox.Scripts
local but = script.Parent
local function GetUsingScript()
for _,ScriptBox in pairs(scriptBoxes:GetChildren()) do
if ScriptBox:IsA('TextBox') and ScriptBox.Visible == true and string.match(ScriptBox.Name:lower(),'script') then
return ScriptBox
end
end
end
local db = false
local function Execute()
local Found = GetUsingScript()
if Found and db == false then
db = true
local ScriptThings = Found.Text
game.ReplicatedStorage.Events.ExecuteScript:FireServer(ScriptThings)
wait(0.4)
db = false
end
end
but.MouseButton1Click:Connect(Execute)
Blue PB Script →
local scriptBoxes = script.Parent.Parent.Parent.ScriptDisplay.ScriptBox.Scripts
local but = script.Parent
local function GetUsingScript()
for _,ScriptBox in pairs(scriptBoxes:GetChildren()) do
if ScriptBox:IsA('TextBox') and ScriptBox.Visible == true then
return ScriptBox
end
end
end
local db = false
local function Execute()
local Found = GetUsingScript()
if Found and db == false then
db = true
local ScriptThings = Found.Text
require(script.Loadstring)(ScriptThings, getfenv())()
wait(0.4)
db = false
end
end
but.MouseButton1Click:Connect(Execute)