Okay, something you need to learn. Mostly variables will not work ESPECIALLY not httpservices, if they are inside a loop. From my knowledge this causes script to crash.
Please utilize the information your gathering to your advantage, thus being not using while wait() do, that will exceed HTTPSERVICE’s requests.
You could try using the pastebin API to retrieve the post. You can’t just do the URL to the post, because Roblox isn’t logged in to your pastebin account, and your pastebin isn’t public or unlisted. It might be more reliable using an API key as it could be that you’re running into a limit of some sort.
Anyway, here is a working example. I still think you should use another solution like MessagingService though:
local HttpService = game:GetService("HttpService")
local URL = "https://pastebin.com/raw/Ber30YMY"
while true do
local success, result = pcall(HttpService.GetAsync, HttpService, URL) --Always use pcall if there is a possibility of an error
if success then
--It worked, result is going to be the data of the site
print(result)
else
warn("Error caught: " .. result) --Since something went wrong, result will instead contain information about the error
end
task.wait(7.5) --Don't spam requests, it will rate limit you within seconds.
end
You really should be using MessagingService instead if you want real-time updates. All you have to do to send and receive announcements is this:
local MessagingService = game:GetService("MessagingService")
MessagingService:SubscribeAsync("Announcements", function(message)
--(Assuming message.Data is just a string)
print("Got an announcement:", message.Data)
end)
MessagingService:PublishAsync("Announcements", "This will be sent to **all** servers!")
--(Keep in mind you should wrap publishasync in a pcall too, it might fail)
It is not only simpler, but faster and better (and probably more reliable) than writing your own hacks and http requests to do something that is already implemented.
local HttpService = game:GetService("HttpService")
local URL = "the url is giving me the same error here in dev fourm"
local Announcement = game:GetService("ReplicatedStorage").ANNOUNCEMENT
while true do
local success, result = pcall(HttpService.GetAsync, HttpService, URL) --Always use pcall if there is a possibility of an error
if success then
Announcement.Value = result
print(result)
else
warn("Error caught: " .. result) --Since something went wrong, result will instead contain information about the error
end
task.wait(7.5) --Don't spam requests, it will rate limit you within seconds.
end
If you have any issues getting something to work with data stores feel free to PM me and i will see what i can do. (Assuming you are going to use data stores)
Nevermind, i figured it out. I don’t think you have HttpEnabled, if you are in a published game then check your game settings.
If it is not a published game, and you haven’t already done this, then this is why it isn’t working. It never struck me that 403 errors come up if you also have http requests disabled.
Run this in the command bar and try running the code again: