Posts: 4
Threads: 1
Joined: Apr 2025
Reputation:
0
just wondering, is this the best way to write this? it works sure, but the code i think could be better but idrk how. instead of asking AI i'm asking here because you guys probably have decent lua knowledge.
Code: -- Caproos
os.execute("title Rbx PG Acc Finder")
print("PGable Rbx Acc Finder - by Caproos")
print("Min UserID: ")
local min = io.read()
print("Max UserID: ")
local max = io.read()
print("Num of Accs")
local num = io.read()
for i = 1, tonumber(num) do
local g = math.random(tonumber(min), tonumber(max))
print("["..tostring(i).."]: https://www.roblox.com/users/"..tostring(g).."/profile")
end
print("finished")
Posts: 7
Threads: 0
Joined: Mar 2025
Reputation:
2
04-20-2025, 07:30 AM
(This post was last modified: 04-20-2025, 08:06 AM by louknt.
Edit Reason: grammar asdfghnj
)
The way the inputs are worded sound a bit odd, as well as the title, so rephrased it a little bit (though that's a nitpick and personal preference if anything lol). The structuring is fine, though in my version it's a tad different due to there being more code. There is a big lack of invalid input handling though. Let's say instead of a number, I inputted a string, which tonumber would be unable to decode, and return nil (having 'for' error, or potentially math.random). There's also no edge-case handling (for example, amount generated exceeds the maximum amount to generate). Tried to fix both of these issues in mine here just for ease of use and intuitivity. Also added some helpful comments as well to help you understand why certain things are how they are (such as why I used io.write rather than print). Anyways, hope this is helpful, and hope you learned something! (Sorry if this is a bit over-engineered lol, tried to still keep it simple, and have it stick to the core task at hand).
Code: -- Caproos
print("Roblox PGable Account Finder - by Caproos") -- I think the print visually looks better first, though feel free to revert this if you prefer having os.execute be first.
os.execute("title Roblox PGable Account Finder") -- Also, changed the name since the shortened words looked weird. Feel free to revert this as well if you prefer the old title (changed the print above as well).
-- Take user input
io.write("Minimum UserID: ") -- 'io.write' allows single-line printing, and unlike print, will not append a newline by default.
local min = io.read()
io.write("Maximum UserID: ")
local max = io.read()
io.write("Amount of accounts to find: ") -- Amount sounds better, feel free to revert though if you prefer 'num'.
local num = io.read()
-- Convert str input to numbers
min = tonumber(min)
max = tonumber(max)
num = tonumber(num)
-- Validate input, make sure all numbers inputted are numbers, and the minimum isn't greater than the maximum.
if not min or not max or not num then
error("Invalid input: Please enter numeric values for minimum, maximum, and amount.")
end
if min < 0 then
error("Invalid input: minimum must be a positive number (above 0)!")
end
if min > max then
error("Invalid input: The minimum amount cannot be greater than the maximum amount.") -- 'math.random' will error if you pass a greater number as the minimum.
end
-- Generate account profile links
local cache = {} -- This table will store user IDs generated, so there isn't repeats.
local tries = 0
local function generate(i)
if tries == 10 then -- If tenth try, make sure we haven't generated every possible user ID. Increment this number to give theg generator more chances to regenerate a random user ID.
if i>max then return -1 end -- If (amount of user IDs generated) > (max amount of user IDs to generate), then return -1, as all possible numbers have been generated.
for i,_ in pairs(cache) do -- Admittedly this might be a little hacky and a tad slow (especially with big amounts of user IDs), but it's still alright I suppose.
for i = min, max do
if not cache[i] then -- If user ID hasn't been generated,
tries = 0 -- reset the tries counter,
cache[i] = true -- mark it as generated, and,
return i -- return said user ID as it hasn't been generated yet. Admittedly, this does make this, technically,
end -- slightly less random, though it is quicker (typically, anyway), and this shouldn't require perfect psuedorandomness.
end
end
-- This realistically shouldn't ever be reached (due to the i>max check above). But, just in case some strange edge-case were to occur, we have this here as a failsafe.
tries = 0
return -1 -- Return -1, all possible numbers have been generated.
end
local id = math.random(min, max) -- Rename 'g' to 'id', sounds better and is more readable.
if cache[id] then tries = tries + 1; return generate(i) end -- User ID already generated before, generate a new one.
cache[id] = true -- Add newly generated to cache, to mark that it has been generated.
return id -- Return the randomly generated user ID.
end
for i = 1, num do
local id = generate(i) -- Generate a random user ID.
if id == -1 then print("All possible UserIDs generated, stopping.."); num = max; break end -- All possible user IDs generated, stop the 'for' loop.
print("["..i.."]: https://www.roblox.com/users/"..id.."/profile") -- No need to tostring, numbers will automatically cast to string when concatinated with a string.
end
print("Finished! Generated "..num.." account"..(num == 1 and "." or "s.")) -- Show amount generated, with an adaptive 's' to handle non-plural and plural cases. Might've been a bit much but I like doing it that way lol.
(Oh, and if the indentation seems off, it's because I originally wrote this with tabs, but apparently the codeblocks here don't support tabs, so I had to replace them with spaces manually)
Posts: 4
Threads: 1
Joined: Apr 2025
Reputation:
0
04-20-2025, 07:39 AM
(This post was last modified: 04-20-2025, 08:04 AM by DrawnCaproos.)
(04-20-2025, 07:30 AM)louknt Wrote: The way the inputs are worded sound a bit odd, as well as the title, so rephrased it a little bit (though that's a nitpick and personal preference if anything lol). The structuring is fine, though in my version it's a tad different due to there being more code. There is a big lack of invalid input handling though. Let's say instead of a number, I inputted a string, which tonumber would be unable to decode, and return nil (having 'for' error, or potentially math.random). There's also no edge-case handling (for example, amount generated exceeds the maximum amount to generate). Tried to fix both of these issues in mine here just for ease of use and intuitivity. Also added some helpful comments as well to help you understand why certain things are how they are (such as why I used io.write rather than print). Anyways, hope this is helpful, and hope you learned something! (Sorry if this is a bit over-engineered lol, tried to still keep it simple, and have it stick to the core task at hand).
Code: -- Caproos
print("Roblox PGable Account Finder - by Caproos") -- I think the print visually looks better first, though feel free to revert this if you prefer having os.execute be first.
os.execute("title Roblox PGable Account Finder") -- Also, changed the name since the shortened words looked weird. Feel free to revert this as well if you prefer the old title (changed the print above as well).
-- Take user input
io.write("Minimum UserID: ") -- 'io.write' allows single-line printing, and unlike print, will not append a newline by default.
local min = io.read()
io.write("Maximum UserID: ")
local max = io.read()
io.write("Amount of accounts to find: ") -- Amount sounds better, feel free to revert though if you prefer 'num'.
local num = io.read()
-- Convert str input to numbers
min = tonumber(min)
max = tonumber(max)
num = tonumber(num)
-- Validate input, make sure all numbers inputted are numbers, and the minimum isn't greater than the maximum.
if not min or not max or not num then
error("Invalid input: Please enter numeric values for minimum, maximum, and amount.")
end
if min < 0 then
error("Invalid input: minimum must be a positive number (above 0)!")
end
if min > max then
error("Invalid input: The minimum amount cannot be greater than the maximum amount.") -- 'math.random' will error if you pass a greater number as the minimum.
end
-- Generate account profile links
local cache = {} -- This table will store user IDs generated, so there isn't repeats.
local tries = 0
local function generate(i)
if tries == 25 then -- If tenth try, make sure we haven't generated every possible user ID. Increment this number to give theg generator more chances to regenerate a random user ID.
if i>max then return -1 end -- If (amount of user IDs generated) > (max amount of user IDs to generate), then return -1, as all possible numbers have been generated.
for i,_ in pairs(cache) do -- Admittedly this might be a little hacky and a tad slow (especially with big amounts of user IDs), but it's still alright I suppose.
for i = min, max do
if not cache[i] then -- If user ID hasn't been generated,
tries = 0 -- reset the tries counter,
cache[i] = true -- mark it as generated, and,
return i -- return said user ID as it hasn't been generated yet. Admittedly, this does make this, technically,
end -- slightly less random, though it is quicker (typically, anyway), and this shouldn't require perfect psuedorandomness.
end
end
-- This realistically shouldn't ever be reached (due to the i>max check above). But, just in case some strange edge-case were to occur, we have this here as a failsafe.
tries = 0
return -1 -- Return -1, all possible numbers have been generated.
end
local id = math.random(min, max) -- Rename 'g' to 'id', sounds better and is more readable.
if cache[id] then tries = tries + 1; return generate(i) end -- User ID already generated before, generate a new one.
cache[id] = true -- Add newly generated to cache, to mark that it has been generated.
return id -- Return the randomly generated user ID.
end
for i = 1, num do
local id = generate(i) -- Generate a random user ID.
if id == -1 then print("All possible UserIDs generated, stopping.."); num = max; break end -- All possible user IDs generated, stop the 'for' loop.
print("["..i.."]: https://www.roblox.com/users/"..id.."/profile") -- No need to tostring, numbers will automatically cast to string when concatinated with a string.
end
print("Finished! Generated "..num.." account"..(num == 1 and "." or "s.")) -- Show amount generated, with an adaptive 's' to handle non-plural and plural cases. Might've been a bit much but I like doing it that way lol.
(Oh, and if the indentation seems off, it's because I originally wrote this with tabs, but apparently the codeblocks here don't support tabs, so I had to replace them with spaces manually)
this might be the most helpful i've ever seen anyone be in a programming forum. thank you so much, and i did learn something haha (quite a few things apparently). also i was wondering if it was possible and how to print something without a newline lol, thanks a lot
[also i changed the max tries from 10 to 25 just to give the generator a bit more leeway to keep the results a bit more random]
Posts: 22
Threads: 3
Joined: Mar 2025
Reputation:
1
(04-20-2025, 07:30 AM)louknt Wrote: The way the inputs are worded sound a bit odd, as well as the title, so rephrased it a little bit (though that's a nitpick and personal preference if anything lol). The structuring is fine, though in my version it's a tad different due to there being more code. There is a big lack of invalid input handling though. Let's say instead of a number, I inputted a string, which tonumber would be unable to decode, and return nil (having 'for' error, or potentially math.random). There's also no edge-case handling (for example, amount generated exceeds the maximum amount to generate). Tried to fix both of these issues in mine here just for ease of use and intuitivity. Also added some helpful comments as well to help you understand why certain things are how they are (such as why I used io.write rather than print). Anyways, hope this is helpful, and hope you learned something! (Sorry if this is a bit over-engineered lol, tried to still keep it simple, and have it stick to the core task at hand).
Code: -- Caproos
print("Roblox PGable Account Finder - by Caproos") -- I think the print visually looks better first, though feel free to revert this if you prefer having os.execute be first.
os.execute("title Roblox PGable Account Finder") -- Also, changed the name since the shortened words looked weird. Feel free to revert this as well if you prefer the old title (changed the print above as well).
-- Take user input
io.write("Minimum UserID: ") -- 'io.write' allows single-line printing, and unlike print, will not append a newline by default.
local min = io.read()
io.write("Maximum UserID: ")
local max = io.read()
io.write("Amount of accounts to find: ") -- Amount sounds better, feel free to revert though if you prefer 'num'.
local num = io.read()
-- Convert str input to numbers
min = tonumber(min)
max = tonumber(max)
num = tonumber(num)
-- Validate input, make sure all numbers inputted are numbers, and the minimum isn't greater than the maximum.
if not min or not max or not num then
error("Invalid input: Please enter numeric values for minimum, maximum, and amount.")
end
if min < 0 then
error("Invalid input: minimum must be a positive number (above 0)!")
end
if min > max then
error("Invalid input: The minimum amount cannot be greater than the maximum amount.") -- 'math.random' will error if you pass a greater number as the minimum.
end
-- Generate account profile links
local cache = {} -- This table will store user IDs generated, so there isn't repeats.
local tries = 0
local function generate(i)
if tries == 10 then -- If tenth try, make sure we haven't generated every possible user ID. Increment this number to give theg generator more chances to regenerate a random user ID.
if i>max then return -1 end -- If (amount of user IDs generated) > (max amount of user IDs to generate), then return -1, as all possible numbers have been generated.
for i,_ in pairs(cache) do -- Admittedly this might be a little hacky and a tad slow (especially with big amounts of user IDs), but it's still alright I suppose.
for i = min, max do
if not cache[i] then -- If user ID hasn't been generated,
tries = 0 -- reset the tries counter,
cache[i] = true -- mark it as generated, and,
return i -- return said user ID as it hasn't been generated yet. Admittedly, this does make this, technically,
end -- slightly less random, though it is quicker (typically, anyway), and this shouldn't require perfect psuedorandomness.
end
end
-- This realistically shouldn't ever be reached (due to the i>max check above). But, just in case some strange edge-case were to occur, we have this here as a failsafe.
tries = 0
return -1 -- Return -1, all possible numbers have been generated.
end
local id = math.random(min, max) -- Rename 'g' to 'id', sounds better and is more readable.
if cache[id] then tries = tries + 1; return generate(i) end -- User ID already generated before, generate a new one.
cache[id] = true -- Add newly generated to cache, to mark that it has been generated.
return id -- Return the randomly generated user ID.
end
for i = 1, num do
local id = generate(i) -- Generate a random user ID.
if id == -1 then print("All possible UserIDs generated, stopping.."); num = max; break end -- All possible user IDs generated, stop the 'for' loop.
print("["..i.."]: https://www.roblox.com/users/"..id.."/profile") -- No need to tostring, numbers will automatically cast to string when concatinated with a string.
end
print("Finished! Generated "..num.." account"..(num == 1 and "." or "s.")) -- Show amount generated, with an adaptive 's' to handle non-plural and plural cases. Might've been a bit much but I like doing it that way lol.
(Oh, and if the indentation seems off, it's because I originally wrote this with tabs, but apparently the codeblocks here don't support tabs, so I had to replace them with spaces manually)
if you know any good pg methods then you should say them lul
Posts: 9
Threads: 1
Joined: May 2025
Reputation:
0
(04-20-2025, 08:26 AM)OffSet Wrote: (04-20-2025, 07:30 AM)louknt Wrote: The way the inputs are worded sound a bit odd, as well as the title, so rephrased it a little bit (though that's a nitpick and personal preference if anything lol). The structuring is fine, though in my version it's a tad different due to there being more code. There is a big lack of invalid input handling though. Let's say instead of a number, I inputted a string, which tonumber would be unable to decode, and return nil (having 'for' error, or potentially math.random). There's also no edge-case handling (for example, amount generated exceeds the maximum amount to generate). Tried to fix both of these issues in mine here just for ease of use and intuitivity. Also added some helpful comments as well to help you understand why certain things are how they are (such as why I used io.write rather than print). Anyways, hope this is helpful, and hope you learned something! (Sorry if this is a bit over-engineered lol, tried to still keep it simple, and have it stick to the core task at hand).
Code: -- Caproos
print("Roblox PGable Account Finder - by Caproos") -- I think the print visually looks better first, though feel free to revert this if you prefer having os.execute be first.
os.execute("title Roblox PGable Account Finder") -- Also, changed the name since the shortened words looked weird. Feel free to revert this as well if you prefer the old title (changed the print above as well).
-- Take user input
io.write("Minimum UserID: ") -- 'io.write' allows single-line printing, and unlike print, will not append a newline by default.
local min = io.read()
io.write("Maximum UserID: ")
local max = io.read()
io.write("Amount of accounts to find: ") -- Amount sounds better, feel free to revert though if you prefer 'num'.
local num = io.read()
-- Convert str input to numbers
min = tonumber(min)
max = tonumber(max)
num = tonumber(num)
-- Validate input, make sure all numbers inputted are numbers, and the minimum isn't greater than the maximum.
if not min or not max or not num then
error("Invalid input: Please enter numeric values for minimum, maximum, and amount.")
end
if min < 0 then
error("Invalid input: minimum must be a positive number (above 0)!")
end
if min > max then
error("Invalid input: The minimum amount cannot be greater than the maximum amount.") -- 'math.random' will error if you pass a greater number as the minimum.
end
-- Generate account profile links
local cache = {} -- This table will store user IDs generated, so there isn't repeats.
local tries = 0
local function generate(i)
if tries == 10 then -- If tenth try, make sure we haven't generated every possible user ID. Increment this number to give theg generator more chances to regenerate a random user ID.
if i>max then return -1 end -- If (amount of user IDs generated) > (max amount of user IDs to generate), then return -1, as all possible numbers have been generated.
for i,_ in pairs(cache) do -- Admittedly this might be a little hacky and a tad slow (especially with big amounts of user IDs), but it's still alright I suppose.
for i = min, max do
if not cache[i] then -- If user ID hasn't been generated,
tries = 0 -- reset the tries counter,
cache[i] = true -- mark it as generated, and,
return i -- return said user ID as it hasn't been generated yet. Admittedly, this does make this, technically,
end -- slightly less random, though it is quicker (typically, anyway), and this shouldn't require perfect psuedorandomness.
end
end
-- This realistically shouldn't ever be reached (due to the i>max check above). But, just in case some strange edge-case were to occur, we have this here as a failsafe.
tries = 0
return -1 -- Return -1, all possible numbers have been generated.
end
local id = math.random(min, max) -- Rename 'g' to 'id', sounds better and is more readable.
if cache[id] then tries = tries + 1; return generate(i) end -- User ID already generated before, generate a new one.
cache[id] = true -- Add newly generated to cache, to mark that it has been generated.
return id -- Return the randomly generated user ID.
end
for i = 1, num do
local id = generate(i) -- Generate a random user ID.
if id == -1 then print("All possible UserIDs generated, stopping.."); num = max; break end -- All possible user IDs generated, stop the 'for' loop.
print("["..i.."]: https://www.roblox.com/users/"..id.."/profile") -- No need to tostring, numbers will automatically cast to string when concatinated with a string.
end
print("Finished! Generated "..num.." account"..(num == 1 and "." or "s.")) -- Show amount generated, with an adaptive 's' to handle non-plural and plural cases. Might've been a bit much but I like doing it that way lol.
(Oh, and if the indentation seems off, it's because I originally wrote this with tabs, but apparently the codeblocks here don't support tabs, so I had to replace them with spaces manually)
if you know any good pg methods then you should say them lul true xd idk how some ppl are so good at pging or know so many good pg methods i cant find any good ones all of the ones i know or found are shit ngl and idk where or how ppl find such good ones or how ppl even come up with such good methods and how ppl are even so good at pging at all xd
|