local Button = script.Parent
local frm = script.Parent.Parent.Parent.Group
frm.Visible = false
function onClick()
local rank=frm.Ranks
local max = script.Parent.Parent.MaxTextBox.Text
local min = script.Parent.Parent.MinTextBox.Text
local frm = script.Parent.Parent.Parent.Group
local Url = frm.Url
local desc = frm.Desc
local name = frm.name
local owner = frm.Owner
local img = frm.ImageLabel
--local memberCount = frm.memberCount
frm.Visible = true
print(max)
print(min)
repeat
local groupId = math.random(min,max)
print(groupId)
local group = game:GetService("GroupService"):GetGroupInfoAsync(groupId)
wait(0.006)
if group ~= nil then
if group.publicEntryAllowed == true then
if group.Owner == nil then owner.Text = "No One!"
Url.Text = 'https://www.roblox.com/groups/'..groupId.."/"..group.Name
desc.Text = group.Description
img.Image = group.EmblemUrl
name.Text = group.Name
--memberCount.Text = "Members:" .. group.MemberCount
for _, role in ipairs(group.Roles) do
rank.Text = ("Rank " .. role.Rank .. ": " .. role.Name)
end
wait(0.5)
else groupId = math.random(min,max) and owner.Text == group.Owner.Name
end
end
end
until group.Owner == nil and group.publicEntryAllowed == true
end
Button.MouseButton1Click:connect(onClick)
this is the code but i changed it a bit so I don't know if it works like it did originally.
Right now it stops whenever it fails because of HTTP 404 (Not Found)

3 comments
(line 21 is where it errors if it wasn't obvious)
(BTW it also doesnt fail all of the time
I just realized there may be a better way to do this than GetGroupInfoAsync()