Storing code on a web server not working

Hey developers, I am currently making a system to store code off roblox but my Http request goes through but my code does not run and I don’t know why.
Server Script:

local httpservice = game:GetService("HttpService")
local response = httpservice:GetAsync("http://localhost:5265/noob")

function load()
	loadstring(response)
end
wait(5)
load()

Web Server Script:

const express = require('express');
var app = express();
const bodyparser = require('body-parser');

app.use(bodyparser.urlencoded({ extended: false }));
app.use(bodyparser.json());
app.get('/noob', (req, res) => {
  res.send(`print("Hello World")`)
  console.log("REC")
});
app.listen(5265, () => {
  console.log(`App is listening on port 5265`)
});

If you can help with this please leave a post below.

loadstring returns a function when it succeeds, and nil followed by an error string when it fails. You aren’t handling either case here. For the code to run, you should be calling the function returned after ensuring there were no errors.

3 Likes

@Autterfly described your situation perfectly.
However, I want to ask: why do you have a wait(5) in the mix?

Thanks so just to clarify the loaded code doesn’t instantly execute so how do I execute it?

-- func is nil when there's an error
local func, err = loadstring(code)

if func == nil then
   print(err) -- you might want to handle the error some other way
else
    func() -- this calls the function with your code
end
1 Like

Thanks I have a better understanding now.