How to use math.random() with number above the 32 bit integer limit

Currently, the integer limit for math.random() is 2147483647. Is there any way to use math.random() and go over the integer limit? I was hoping to find an answer so I can generate games up to 2023, not 2018 (which is the limit currently for my random game generator)

Script

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid=".. id .."&fmt=png&wd=420&ht=420"
	local Info = MarketplaceService:GetProductInfo(id,Enum.InfoType.Asset)

	if Info.AssetTypeId == 9 then
		return {
			Name = Info.Name,
			Created = Info.Created,
			Updated = Info.Updated,
			Description = Info.Description,
			Thumbnail = thumbnail,
		}
	end
end

local Check = function(id)
	local Info = MarketplaceService:GetProductInfo(id,Enum.InfoType.Asset)
	if string.find(Info.Name, "Place") then
		return false
	end
	return true
end

local IgnoredPlaceIds = {}
local function GRP()
	-- Generates a Random Place
	local RandomPlaceGenerator = math.random.new(100000, 2147483647)

	-- Checks for the word Place Before anything
	if not Check(RandomPlaceGenerator) then
		GRP()
		return
	end

	-- Checks if the player has recieved this place before OR contains Place in it
	if table.find(IgnoredPlaceIds, RandomPlaceGenerator) then
		GRP()
		return
	end

	-- This Line Make its so you cant get the same place your recieved before.
	table.insert(IgnoredPlaceIds, RandomPlaceGenerator)

	local success, errormessage = pcall(function()
		-- Recieves Information Needed
		local RecieveInformation = GetInfo(RandomPlaceGenerator)

		-- Fills out returned information
		local SurfaceGUI = script.Parent.Parent.Parent.SurfaceGui
		SurfaceGUI.Thumbnail.Image = RecieveInformation.Thumbnail
		SurfaceGUI.PlaceName.Text = RecieveInformation.Name
		SurfaceGUI.CreationDate.Text = RecieveInformation.Created
		SurfaceGUI.LastUpdated.Text = RecieveInformation.Updated
		SurfaceGUI.Visits.Text = RecieveInformation.Description
	end)
	if not success then
		warn(errormessage)
		GRP()
		return
	else
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(RandomPlaceGenerator, player)
		end)
	end


end

while task.wait(10) do
	GRP()
	end
1 Like

Have you tried using math.random(0,9) for each digit, selecting a random number of digits? You can just add these digits to a string, it doesn’t need to be an integer (since its an assetid anyway).

2 Likes

Use Random.new(). It uses 64 bits.
Example:

print(Random.new():NextInteger(100000, 2147483647))
2 Likes

Oh my gosh you are a genius. Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.