This is my array but when I do, Name.Text = Pets[1][1] it comes up with 1.5 instead of the name “Shadow” How do I get it to do the name instead of the 1.5.
is there a reason why you’re using an array of pets over a dictionary?
local Pets = {
["shadow"] = {
["name"] = "Shadow",
["coin_multiplier"] = 1.5,
["gem_multiplier"] = 1.2,
["price"] = 1000,
["unknown"] = 19283, -- Not sure what this is since it's not an image
["image"] = "rbxassetid://0"
};
["unicorn"] = {
["name"] = "Unicorn",
["coin_multiplier"] = 2,
["gem_multiplier"] = 1.2,
["price"] = 5000,
["unknown"] = 19283,
["image"] = "rbxassetid://0"
};
["pegasus"] = {
["name"] = "Pegasus",
["coin_multiplier"] = 3,
["gem_multiplier"] = 2.5,
["price"] = 15000,
["unknown"] = 19283,
["image"] = "rbxassetid://0"
};
}
-- ^ Pets could be a ModuleScript instead
-- local Pets = require(ReplicatedStorage.Pets)
local function onClick()
local TargetPet = Pets[Button1.ID.Value:lower()] -- Should be a StringValue instead
info.Info.petname.Text = TargetPet.name
info.Info.Coin.coinmulti.Text = TargetPet.coin_multiplier
info.Info.Gem.gemmulti.Text = TargetPet.gem_multiplier
info.Info.Cost.price.Text = TargetPet.price
info.Info.ImageLabel.Image = TargetPet.image-- I'm assuming you removed the images from Pets
-- info.Info is a bad way to name things
-- you could use a for loop if you named your stuff properly
--[[
for _, PetProperty in info.Info:GetChildren() do
if not PetProperty:GetAttribute("IsPetProperty") then continue end
PetProperty.Text = TargetPet[PetProperty.Name]
end
]]
end
You can optimize your code to look more clean like this. (This is just an example, it may not work in your case)
local function onClick()
local id = button1.ID.Value
info.Info.petname.Text = Pets[id][1]
info.Info.Coin.coinmulti.Text = Pets[id][2]
info.Info.Gem.gemmulti.Text = Pets[id][3]
info.Info.Cost.price.Text = Pets[id][4]
info.Info.ImageLabel.Image = Pets[id][5]
end