Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you use HTTPService with a module script?

Asked by 6 years ago

I'm trying to make a discord bot/webhook in a module script so I can execute it whenever I want. If I use it, all it does is error: HTTP 400 (HTTP/1.1 400 Bad Request) I have been having a hard time with this and have been searching for an hour and a half with no answers for roblox scripting.

0
I hope this question gets answered and doesn't have the fate of going unanswered. mightydifferent 85 — 6y
0
Well how are you attaining the module? Are you keeping the modules scope or the callers? If you just make the module try to request any http it will fail, you can however load the module like a variable list and run it though an environment that normally can make requests. Bellyrium 310 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The answer to your question is "It can". You see, a ModuleScript can be run from the server or the client. If you require the ModuleScript from a Script, it is running on the server and so will be fine (since you can only use HttpService from the server). Similarly, it won't work if it's a LocalScript that requires it.

Since you're getting that error, I believe this confirms that you are referencing HttpService correctly and from the right place - the problem is that you're using it incorrectly (sending in a bad http request).

See here for details on HttpService; it also has links on how to properly send requests.

Ad

Answer this question