How to get a specific value from dictionary?

local Pets = {
   ["Dog"] = {Price = 10},
   ["Cat"] = {Price = 15}
}

Buy.OnServerEvent:Connect(function(player,pet)
   if CashTable[player.UserId] >= ??? then
      CashTable[player.UsedId] = CashTable[player.UserId] - ???
   end
end)

I am trying to get a specific price from the dictionary based on what was sent from the client. How do I achieve this?? Like if the player clicked on dog the price will return 10 and if player cat, price would be 15

2 Likes
CashTable[player.UserId] - Pets[pet]["Price"]

Since you’re accessing a key in a dictionary, all you need to do is index the table like any other array.

4 Likes