Hi,
So recently I’ve been working on making a DFFlag system for my game. Roblox’s own FFlag system has always intrigued me, so I wanted to make one for myself. I’ve already gotten the FFlag system down, and I think I might have gotten the DFFlag system working great, but I would like some feedback on it. More information on Flags can be here.
FFlag’s and DFFlags are great ways of testing updates, if something goes wrong I can flick off a flag without actually having to update my game. While the system works, I’ve noticed it can be a bit slow. GitHub hosting can take up to 5 minutes to update, which isn’t the problem. Even when I see the exact data that is being called from the GET
request, it doesn’t always update until a couple tries. I’m guessing that’s due to some inefficiency in my code I’ve overlooked.
I’m using JSON to control the flags, it’s easiest for me because I can quickly change the flag via VSC and then commit and push to GitHub hosting in around 30 seconds.
Anyway, onto the code:
JSON Configuration (Flag Storage)
{
"test1" : true,
"level1open" : true,
"allfflagsenabled" : true
}
Lua Code
local HttpService = game:GetService("HttpService")
local function request()
local response = HttpService:RequestAsync(
{
Url = "https://raw.githubusercontent.com/FxllenCode/TheInternFFlags/main/fflags.json",
Method = "GET",
Headers = {
["Cache-Control"] = "no-cache"
}
}
)
if response.Success then
print("Status code:", response.StatusCode, response.StatusMessage)
local data = response.Body
local parsed = HttpService:JSONDecode(data)
if parsed.level1open == true then
print("Level 1 is open.") -- other stuff too
elseif parsed.level1open == false then
print("Level 1 is closed.") -- other stuff too
end
else
print("The request failed:", response.StatusCode, response.StatusMessage)
end
end
while true do
local success, message = pcall(request)
if not success then
print("Http Request failed:", message)
end
wait(300)
end