Server script (where the error is coming from) inside of ServerScriptService:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() local text = tostring(game.ReplicatedStorage.Value.Value) game.ReplicatedStorage.Value2.Value = loadstring(text) end)
Local script inside of StarterGui (no errors):
while true do wait() local tocompile = script.Parent.Text game.ReplicatedStorage.RemoteEvent:FireServer() game.ReplicatedStorage.Value.Value = script.Parent.Text wait() script.Parent.Parent.TextLabel.Text = game.ReplicatedStorage.Value.Value end
Anyone know why this is happening?
P.S. When using a print(text)
in the serverscript it prints print("Hello world"), which is the value but that would mean that loadstring()
isn't working.
EDIT:
Server script (where the error is coming from) inside of ServerScriptService:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, text) loadstring(text)() end)
Local script inside of StarterGui (no errors):
while true do wait() game.ReplicatedStorage.RemoteEvent:FireServer(script.Parent.Text) end
How do you change the textlabels text to the loadstring instead of just printing it?
Client Code:
--###----------[[SERVICES]]----------###-- local ReplicatedStorage = game:GetService("ReplicatedStorage") --###----------[[VARIABLES]]----------###-- local CompileCode = ReplicatedStorage:WaitForChild("CompileAndExecute") local GUIMain = script.Parent local CodeForm = GUIMain:WaitForChild("CodeForm") local CompileButton = CodeForm:WaitForChild("CompileButton") local OutputText = CompileButton:WaitForChild("OutputText") --###----------[[FUNCTIONS]]----------###-- local function OnButtonClick() local CodeToCompile = CodeForm.Text --------------- local CompiledSuccessfully, ExecutionResult = CompileCode:InvokeServer(CodeToCompile) --------------- OutputTextLabel.Text = "Compiled with exit code "..(CompiledSuccessfully and 0 or 1).."! "..(ExecutionResult or '') end --###----------[[SIGNALS]]----------###-- CompileButton.MouseButton1Click:Connect(OnButtonClick)
Server Code:
--###----------[[SERVICES]]----------###-- local ReplicatedStorage = game:GetService("ReplicatedStorage") --###----------[[VARIABLES]]----------###-- local ExecuteCode = ReplicatedStorage:WaitForChild("CompileAndExecute") local ErrorFormatTemplate = "(%d: .*)" --###----------[[FUNCTIONS]]----------###-- local function OnCodeRecieved(_, Code) local Executable, Error = loadstring(Code) --------------- if not (Error) then --------------- Executable() --------------- return true else return false, Error:match(ErrorFormatTemplate) end end --###----------[[SIGNALS]]----------###-- ExecuteCode.OnServerInvoke = OnCodeRecieved