Ok so i am working on a public script and i am wondering on how i can check if the game the script is being ran in has HttpsService enabled, the script will need HttpService for some functions and i would like to warn the owner of the problem, all i need help with is to check if the game has HttpsService is enabled. Thanks anyone who awensers.
local HttpService = game:GetService("HttpService") local CheckHttp = function() local Set = false pcall(function() if HttpService:GetAsync("https://www.test.com/") then Set = not Set end end) return Set end if CheckHttp() then -- returns either true or false print('works!') else print('uh oh it doesnt work!') end
Pretty simple actually, pcall comes useful to situations such as these, as JakyeRU said to use pcall. This is an example, hope you learned a thing.
You can use the command bar in Roblox Studio to check if HTTP requests are enabled in a game:
print(game.HttpService.HttpEnabled) -- Returns a boolean determining if HTTP requests are enabled