I have a problem, I run :InvokeServer() on a remotefunction, like this:
local itemname = "Chopin"
local specificItem = itemrem:InvokeServer(itemname)
if specificItem then
print("yup got it")
print(specificItem)
end
the remote function is hooked like this:
local function item(player, v)
return Mod.GetItemByName(v)
end
itemrem.OnServerInvoke = item
and then the module script runs this:
function ShopModule.GetItemByName(v)
local itemTable = {}
for _, item in ipairs(shopItems) do
if tostring(item.name) == tostring(v) then
print("found")
table.insert(itemTable, {
Name = item.name,
Type = item.itemtype,
Description = item.description,
Price = item.price,
Object = item.object,
Title = item.title,
TitleColor = item.titlecolor,
RotationAngle = item.rotationangle
})
end
end
print(itemTable)
return itemTable
end
every print except the ones that actually contain the value are printed, which includes
if specificItem then
print("yup got it")
print(specificItem) -- <-not this one though
end
but the specific item i requested does NOT get printed out, however if i add a simple wait(1) before checking if specificItem exists, the problem dissapears
so my question is - how do i wait for invokeserver() to completely return the table?