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

How do I make a button on a GUI run HTTPService?

Asked by
SpiralRBX 224 Moderation Voter
6 years ago

I have a GUI that is supposed to load scripts from Pastebin in onClick. It doesn't seem to be doing its job. I did further research and learned that you can't run HTTPService with a LocalScript. I was wondering how I might be able to make it so when you click a button on a GUI it will run the HTTPService, loading in a script from Pastebin.

PS: This is not for any malicious content. I'm working on an admin and think this will help lag problems.

0
use remote events for the client to communicate to the server User#23365 30 — 6y

1 answer

Log in to vote
1
Answered by
metryy 306 Moderation Voter
6 years ago
Edited 6 years ago

You can only send HTTP requests on the server which means you'll have to use remotes to be able to communicate to the server.

Example:

Client:

button.MouseButton1Click:Connect(function()
    local data = RemoteFunction:InvokeServer()
    -- now that you have the data you want from the httprequest made on the server you can do whatever you want with it here
end)

Server:

RemoteFunction.OnServerInvoke = function() 
    local response = game:GetService( HttpService"):GetAsync("http://example.org/json-table", true)
    local data = game:GetService("HttpService"):JSONDecode(data)

    return data
end)
0
I'm planning on turning this GUI into LUA. Any help? SpiralRBX 224 — 6y
0
You can use the Instance.new(Class, Parent) to create a new object. If you found my answer helpful, click "Choose this answer" on my answer, thanks! :) metryy 306 — 6y
0
Thanks! SpiralRBX 224 — 6y
Ad

Answer this question