Hi, I want to make a remote admin panel using HttpService. This is how I was thinking I should do things:
- The game owner goes on my website
- A command is chosen and added to the database
- Every second, the game sees if a new command was added to the database
- If there is a new command, the command is run
- Repeat every 1 second However, I was wondering if there was a way to do this without having:
while wait(1) do -- stuff end
Thank you! * Link43758
Unfortunately, no. The HTTP service only allows you to request a page, and cannot accept one that the webserver sends of its own accord (HTTP as a protocol doesn't allow this).
If performance is a concern, though, you could do a few things to reduce webserver requests and Lua operations.
Consider only requesting every 20 seconds or so usually; however, each response from the panel states whether or not someone recently logged onto the admin panel; if so, the ROBLOX server increases the request rate to once per second.
That way, if an operation takes at least 20 seconds to perform from logging on, you'll get it just as fast but on average send 5% as many requests.
You could also reduce requests caused by having multiple ROBLOX servers open by conferring with DataStores to essentially have only one ROBLOX server sending requests at a time, though this might have a more significant Lua performance cost (but some better network / admin webserver performance)
It's not clear from your question, so I'll make the recommendation:
Your ROBLOX Lua script should probably not be the thing identifying if something has changed. This should probably be handled by the webserver so that significantly less information is sent across and less information needs to be processed.
Best way to do this is to send to the webserver the timestamp of the last request, and only share messages made since then (maybe plus a bit to be safe).
Do you want to run the function when any propety of an item is changed? if so,
script.Parent.Changed:connect(function(pt) --stuff end) Changed is a variable for nearly everything..