Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast Array to int?

local Tool = game:GetService("InsertService"):LoadAsset(List[math.random(#List)])

List is a table of tables containing information about the gear it's loading, but I can't get it to load Output : Unable to cast Array to int? Format of the tables

List = {
[1] = {[1] = "16895215"; [2] = "Darkheart"; [3] = "246454502"; [4] = "It's darker than RGB(0,0,0) and it steals \n life from your enemies. What more is there to say."};
[2] = {[1] = "23727705"; [2] = "Spec Epsilon Biograft Energy Sword"; [3] = "246455445"; [4] = "The superintelligent cloud people of the \n distant future find the history of human conflict hilarious and ironic."};
[3] = {[1] = "14876573"; [2] = "Spec Beta Biograft Energy Sword"; [3] = "246456657"; [4] = "In 2113, decades after the initial release of the hugely successful Spec Alpha biograft energy weapons"};
[4] = {[1] = "16641274"; [2] = "Illumina"; [3] = "246455445"; [4] = "Telamon's favorite weapon from Sword Fight on the Heights."};
}

1 answer

✓ Accepted answer

If what you're saying is you have a table of tables. You are trying to load an asset which is a number with a table. I don't have all the information so I kind of have to guess here but. I'm assuming you have a value in the table named "ID" and it is a NUMBER.

local Tool = game:GetService("InsertService"):LoadAsset(List[math.random(#List)].ID) --Adding ID after will grab the ID value of the table. 

In other words you're using a table where a number should be.

4 comments

3

The id # is listed in the table as a string

3

nvm i got it

3

Congrats on becoming a Scholar =

1

Thanks :D

This discussion is preserved as it was. New answers, comments, and votes are closed.