Hello, I can’t figure out how to access my variables that are inside of a table.
researchitems = {
["Label"] = {
level = 1,
cost = 15
}
}
function checkLevel(obj)
for object, params in pairs(researchitems) do
if object == obj then
local level = params[1]
return(level)
end
end
end
function checkCost(obj)
for object, params in pairs(researchitems) do
if object == obj then
local cost = params[2]
return(cost)
end
end
end
game.ReplicatedStorage.Research.OnServerEvent:Connect(function(player, object)
local level = checkLevel(object)
local cost = checkCost(object)
print(level, cost)
end)
It prints nil as the level and cost, i can’t figure out why.