Need help making my game DevForum member only

Greetings! After searching a lot on the Roblox Developer forum, I found out how to write this:

local HttpService = game:GetService("HttpService")

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local DevForumURL = "https://devforum.rprxy.xyz/u/".. Player.Name..".json/"
	
	local Success, TrustLevel = pcall(function()
		return HttpService:JSONDecode(HttpService:GetAsync(DevForumURL)).user.trustlevel
	end)
	
	if Success then
		if TrustLevel >= 1 then
			print("Player, ".. Player.UserId.. "Is allowed")
		else
			Player:Kick("This version of the game is only avilable to Roblox Developers, as this is a Developer Beta.")
		end
	else
		Player:Kick("Error checking trust level on Roblox Developer Forum.")
	end
end)

I am trying to make my game Developer Forum Member only. It may sound silly at first, but I do not want the average player playing Developer Betas, as they are unfinished, and can tend to be very buggy.

The problem with this script is that it kicks after checking with the pcall, saying it failed to check the trust level.

If you can help make my game DevForum member only, that will be appreciated!

Thanks in advance!

rprxy is no longer available, you might want to consider using a different proxy.

What proxy should I use instead?

After doing some more DevForum digging, I created this solution by finding some already existing code with a different Proxy:

local HS = game:GetService("HttpService")
local Url = "https://devforum.roblox.com/u/%s.json"
local Proxy = "https://cors-anywhere.herokuapp.com/"

local function GetTrustLevel(name)
	local res = HS:RequestAsync({
		Url = Proxy .. Url:format(name),
		Method = "GET",
		Headers = {
			["X-Requested-With"] = "XMLHttpRequest"
		}
	})
	if not res.Success then
		return "None" --no account or error
	end

	local json = HS:JSONDecode(res.Body)

	return tonumber(json.user.trust_level) -- 0 = non-member, 1= member, 2 = regular, etc
end

game:GetService("Players").PlayerAdded:Connect(function(Player)
	local TrustLevel = GetTrustLevel(Player.Name)
	if TrustLevel >= 1 then
		print("Player can come in")
	else
		Player:Kick("This version of the game is only avilable to Roblox Developers, as this is a Developer Beta.")
	end
end)
1 Like