Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

use remote events for the client to communicate to the server

1 answer

✓ Accepted answer

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)

3 comments

0

I'm planning on turning this GUI into LUA. Any help?

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! :)

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.