How can I get this value out of this table?

Hey developers, sorry I’m not experienced with tables and I’m getting nil when I print the pizza help would be appreciated.

local ServerStorage = game:GetService("ServerStorage")

local Order = ServerStorage.UI.Order
local Orderswall = game.Workspace.OrdersWall.Orders
local menu  = {
	1 == "Cheese Pizza", 
	2 == "Coke", 
	3 == "Big Mac", 
	4 == "Peperoni Pizza", 
	5 == "Chips"
}
local cooldown = script.Cooldown.Value
local maxOrderAmount = 5 

local function order()
	if cooldown == 0 and Orderswall.MaxOrders.Value > #Orderswall:GetChildren() then 
		local newOrder = Order:Clone()
		newOrder.Parent = Orderswall
		for i = 1, maxOrderAmount do
			local number = math.random(1, 5)
			local pizza = table.find(menu, menu[number])
			print(pizza)
			local itemUI = newOrder.Items.Item:Clone()
		end
	end
end

order()
1 Like

just do menu[number] without the table.find

2 Likes

this is what I get with that
image

local ServerStorage = game:GetService("ServerStorage")

local Order = ServerStorage.UI.Order
local Orderswall = game.Workspace.OrdersWall.Orders
local menu  = {
	1 == "Cheese Pizza", 
	2 == "Coke", 
	3 == "Big Mac", 
	4 == "Peperoni Pizza", 
	5 == "Chips"
}
local cooldown = script.Cooldown.Value
local maxOrderAmount = 5 

local function order()
	if cooldown == 0 and Orderswall.MaxOrders.Value > #Orderswall:GetChildren() then 
		local newOrder = Order:Clone()
		newOrder.Parent = Orderswall
		for i = 1, maxOrderAmount do
			local number = math.random(1, 5)
			local pizza = menu[number]
			print(pizza)
			local itemUI = newOrder.Items.Item:Clone()
		end
	end
end

order()

Its because youre comparing if a number equals a string in the whole table, the table should look something like this:

local menu  = {
	"Cheese Pizza", 
	"Coke", 
	"Big Mac", 
	"Peperoni Pizza", 
	"Chips"
}
1 Like

I am pretty sure that the table.find function only finds strings and not numbers. Correct me if I’m wrong.

1 Like

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