How do you print out a random value from table?

Hello I have a basic question. Does anyone know
how to print out a table inside of a table?

local SFXWEAPON = { 
	Pistol = {'rbxassetid://15730646395','rbxassetid://15730646395'},
	Sniper = {'rbxassetid://15730650090'},
	OneShot = {'rbxassetid://15730648071','rbxassetid://15730648578'},
	Auto = {'rbxassetid://15730644695','rbxassetid://15730645241',
		'rbxassetid://15730645692','rbxassetid://15730646395',	
	}
}

Basically, for every key (Pistol, Sniper, OneShot) you have, you can put the strings of all of them into a table. Then, you would get a random item from that table and get that item’s value from the dictionary.

local SFXWEAPON = { 
	Pistol = {'rbxassetid://15730646395','rbxassetid://15730646395'},
	Sniper = {'rbxassetid://15730650090'},
	OneShot = {'rbxassetid://15730648071','rbxassetid://15730648578'},
	Auto = {'rbxassetid://15730644695','rbxassetid://15730645241', 'rbxassetid://15730645692','rbxassetid://15730646395'}
}

local NAMES = {"Pistol", "Sniper", "OneShot", "Auto"}

local randomWeapon = SFXWEAPON[NAMES[math.random(#NAMES)]]
print(randomWeapon)

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