So I have this script that selects a random item in the pets table but it prints the amount of characters the name contains rather than the actual name. An example of this would be "Selected 5". I am wondering how to change this to make it print the item name. An example would be "Selected Fire Sword".
local Pets = {
rarities = {0.6,0.4};
pets = {
{
name="Part";
rarity="Rare";
};
{
name="Part2";
rarity="Legendary";
};
};
};
local totalweight = 0
for _,v in ipairs(Pets.rarities) do
totalweight = totalweight + v
end
local at = math.random() * totalweight
for i,v in pairs(Pets.rarities) do
if at < v then
print(Pets.pets[i] .. " has been chosen!")
break
end
at = at - v
end

2 comments
It still prints the amount of characters of the name
nvm for some reason it doesn't like if you do #Pets so I had to do Pets thanks alot!