Ad
Log in to vote
0

How do I make it so if the GetGroupInfoAsync() fails that it will move on and choose a new id?

Asked by 14 days ago
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)

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

1 answer

Log in to vote
0
Answered by
ellxiac 78
14 days ago

Using pcall(function() ignores errors

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 = pcall(function() game:GetService("GroupService"):GetGroupInfoAsync(groupId)
        end)
        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)


Ad

Answer this question