ToNumber string to number error

I’ve been trying to get a random gear to insert from this script and I seemingly cannot to convert the string to number I’ve tried using Tonumber and it hasn’t worked whatsoever and gave me an error Any Help would be heavily Appreciated
Here is the code

local gears = {
			"212641536","78730532","121946387","16688968","188853857","467935723","225921000","257810065","116693764","12187348","193769809","30393548","98346415",
			"127506105","212296936","99119158","409745306","11377306","319655993","168141301","170897263","12848902","31314966","517827962","114020480","130113061",
			"10468915","928914739","243790334","1074738432","33866728","22788134","268533852","409746054","150366274","321345839","306971294","1016183873","10472779",
			"30847685","398675172","302502491","97161222","113328094","11452821","101078559","223439643","42845609","439988813","87361995","172248941","928805891",
			"1060280135","15932306","2605965785","11563251","332747438","86494893","477911027","21754543","52627419","467138029","1117745433","168143042","160198658",
			"115377964","42845853","57229357","54130559","163352376","163354553","94233391","236403905","94794833","395205954","11453385","13207169","302281291","53130850",
			"94233344","72644644","141759818","101106419","11999247","226205948","129471121","12890798","189756588","20721924","95354288","1402322831","71597027","116040770",
			"44115926","206798405","28275809","11419319","105289761","186868758","95951330","10758456","16722267","26014536","172246669","1132887630","73829214","11956382",
			"15177716","13745494","30847779","746686384","835780770","430066424","987032734","527383094","30392263","55301897","45754061","2620420065","92142799","522587921",
			"72713855","97161262","330296266","754869699","18409191","365674685","83704190","101110605","346687565","176087640","16726030","31839337","22787248","84417281",
			"12547976","563288952","18474459","356212121","46846246","319656339","47871635","549915884","283755431","97311482","21392199","46846115","25741198","16214845",
			"2350119937","507797529","183355817","80576967","97885552","192456288","57902859","24346755","16979083","22596452","27902388","10727852","172246820","27902303",
			"527384527","10469910","38327125","29532138","163353363","489196923","111876831","30847733","621090617","11450664","123234545","119101539","1074742019",
			"450565762","483899693","161282711","1829110586","1402452608","96669682","880506541","34901961","212296400","20642023","26419811","1380774367","12145515",
			"40493590","2620470482","31839411","12775410","928807470","99797403","33683368","24791472","22152234","34399428","19111894","121925044","202083069","14131602",
			"15176169","31314931","445150567","226206253","402305186","553937189","18482570","14719505","108875172","22788972","53623248","103358098","304721834","163348987",
			"1340206298","425121415","28664212","34398653","15470183","104642566","25974222","15668963","107458429","31314849","41457719","19328185","2620441860","2506347092",
			"236443047","101106464","65546284","35682284","483308681","11999279","110335886","93528414","105189783","105189783","461488745","35201552","35682284","110335886",
			"162857422","63253701","25926517","186521342","99119261","128160832","71597048","98411325","64869947","315573586","150980409","754871615","489197999","215392741",
			"86494914","467895641","221266538","375832969","75550907","1865195740","58574416","161219985","42847923","45941397","1241156565","1360078533","67998086",
			"531702150","66426498","179369914","25535467","163355211","117498775","105351748","335086410","118650365","356213494","1981809272","295460702","3381451677",
			"146026928","152823669","433922317","313532084","346686979","1360077860","375829909","94333296","743692189","313547345","52180871","75906973","65545971",
			"128160929","39258389","22152171","2535102910","2544539559","66896638","427949130","125013830","71422327","49929767","154727343","108158379","170896461",
			"361950297","315574690","149222485","70353298","24659699","185422055","2136389582","2010630652","383608755","21439893","928794651","95258660","102705386",
			"2316759705","317592936","1513260464","287426148","302280931","1230024287","99797381","1180417820","110704033","65082275","74904413","174752553","1230024287",
			"178077177","330295904","88885539","99254437","83021217","19399456","94119269","110337828","148017553","180300142","718234275","24419822","50938765","181550181",
			"89487934","2221406451","127506257","270562881","2409287383","332755212","178076989","98253626","186867645","317593302","114687251","535104095","178076831",
			"13478015","261826521","170903868","10510024","101078524","999866560","329021959","163348758","549914888","72069888","1466341532","64372667","152971952",
			"36913601","108148449","124908832","80576913","163488515","537436448","176087597","1645056094","341110180","152822847","62827121","116040807","1665541125",
			"286527303","1665541125","156467963","675312894","47871597","2435999675","2620521684","48596324","1191149773","61916137","11419882","903199054","73089229",
			"26017478","124128001","110789105","159199218","91445347","23922939","433923430","24294377","150980444","98219158","1047877698","16726984","410001793",
			"1363019628","69964719","105351503","2620524562","1363019628","135472231","150980444","49491736","12187431","69964719","64220952","1363010936","32858586",
			"67319408","183346956","58901335","639343572","24841520","119101595","86492583","10831489","2014853976","68233678","512422543","1560608167","257343434",
			"161220552","1492225511","209980135","472607575","365631067","84417104","939151180","66416616","61459718","113299641","99033296","1241156683","70476451",
			"517827255","170903216","140490812","146047220","19397135","35200756","1076255449","151311761","139581823","85145680","66416590","284135286","172922026",
			"2568113462","57983650","1532311127","98341183","939145471","56561570","20577851","287424705","315565799","58574445","257837994","253485047","24903431",
			"313536525","18971349","1427402900","253485047","467109371","220288951","698862470","928913996","12909278","152233381","2830533679","62827106","361950795",
			"1241586595","346687267","84012460","99610601","936703279","66896565","96493688","139308319","78665215","55027987","75550928","97756645","2261881814","12902404",
			"170896571","304719869","302418416","27848937","2620523875","139577901","542755101","522586178","176087466","1316010086","467109039","188643628","21351465",
			"160189476","1665509807","121385230","169669671","97885508","236403380","116040789","431038614","161075864","51346336","999866081","169602103","19111883",
			"1258015236","99254164","174752400","64647651","35223828","153938986","66823689","81155006","81847533","155662087","99254358","2014805757","153939072",
			"95951359","74385438","48159648","869123788","1241586091","72318993","2045764727","35293856","58880579","445146200","332747874","346687946","154727201",
			"292044716","88885506","454733534","225921724","125013849","79446433","58901481","133315268","86492467","2222652960","1708355542","2222652960","86492467",
			"110337884","1587165780","90718686","27860496","19381970","153939226","103359953","21440120","37821008","62350867","117544573","30649735","17237662","130113146",
			"54694311","42200852","193743245","230758639","1380788230","20048880","128209615","280662903","76170545","1183007014","24839406","243788010","126719093",
			"90220438","1609498185","113299556","19111869","86692539","124127383","95951291","1241587075","90242059","99641902","27494652","18426536","99130630","176087556",
			"1076467071","68848741","1789547756","2846003729","57902997","233657188","110702207","228589017","101078911","81847637","1016184293","709399046","82357123",
			"67319385","99199463","223785065","168142620","261447208","82357123","398122724","2906731998","99199463","846792499","1678349400","15970544","64372659",
			"101191388","178400986","67755182","147143881","1062304136","2163551089","515687734","124126528","98970218","34398938","71597060","2290921705","65969758",
			"37694914","19395497","38861951","152822815","1088051790","953518028","537435862","12504077","1227732454","204095724","2845941219","26945832","223132403",
			"271017537","728207067","164207842","55917409","56561607","49052638","13477940","12187319","108875237","28672001","2230347432","602145262","63721700","146026944",
			"91450692","55302141","78665196","85145757","50938773","1230839551","163350265","160198008","35683911","503957703","939131179","52180858","71037056","939148317",
			"261439002","120307951","1665540132","161230469",}

		local randomizer = math.random(1,#gears)
		local insertservice = game:GetService("InsertService")
		local id = tonumber(randomizer,#gears)
		print(id)
		local asset = insertservice:LoadAsset(id)
		asset.Handle.Position = Vector3.new(1,3,5)
		asset.Parent = game.Workspace

This should be local id = tonumber(gears[randomizer])
But why not just store them as numbers to begin with?

local gears = {
			212641536, 78730532, 121946387, -- rest of code

You wouldn’t need to convert to number then.

When i did math.random on it with the Ids it acted to generate a random number between the id and 1 proof
image
output
image

Try this.
Make sure to put the table up

		local randomizer = math.random(1,#gears)
                local selected = gears[randomizer]
		local insertservice = game:GetService("InsertService")
		local id = tonumber(selected)
		print(id)
		local asset = insertservice:LoadAsset(id)
		asset.Handle.Position = Vector3.new(1,3,5)
		asset.Parent = game.Workspace

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