tables cannot be cyclic

Hello, I got this error and I am not really sure about how to fix it
private pickItem(item: Instance | undefined) {
print("ppick up hell yea");
if (item !== undefined) {
print("item defined");
const selectedSlot: number | undefined = this.UIstateHandle.getSelectedSlot();
if (selectedSlot !== undefined) {
print("slot defined");
const itemID: number | undefined = item.GetAttribute("ItemID") as number;
if (itemID !== undefined) {
print("itemID defined");
const itemClass = getItemRegistry(itemID);
if (itemClass !== undefined) {
print("itemClass defined");
Functions.pickUp.invoke(selectedSlot, itemClass).then((success) => {
print("no more go 3:");
if (success) {
print("sucess? ", success);
Functions.getItemsInfo.invoke().then((itemData: ItemData[]) => {
print("meow");
itemData.forEach((SlotData, _) => {
const Icon = SlotData.Icons[0];
this.UIstateHandle.setItemsInfo(Icon, undefined);
});
});
}
});
}
}
}
}
}
private pickItem(item: Instance | undefined) {
print("ppick up hell yea");
if (item !== undefined) {
print("item defined");
const selectedSlot: number | undefined = this.UIstateHandle.getSelectedSlot();
if (selectedSlot !== undefined) {
print("slot defined");
const itemID: number | undefined = item.GetAttribute("ItemID") as number;
if (itemID !== undefined) {
print("itemID defined");
const itemClass = getItemRegistry(itemID);
if (itemClass !== undefined) {
print("itemClass defined");
Functions.pickUp.invoke(selectedSlot, itemClass).then((success) => {
print("no more go 3:");
if (success) {
print("sucess? ", success);
Functions.getItemsInfo.invoke().then((itemData: ItemData[]) => {
print("meow");
itemData.forEach((SlotData, _) => {
const Icon = SlotData.Icons[0];
this.UIstateHandle.setItemsInfo(Icon, undefined);
});
});
}
});
}
}
}
}
}
(ignore the print statements, I am debugging) only thing I discovered is it's about this line:
Functions.getItemsInfo.invoke().then((itemData: ItemData[]) => {
Functions.getItemsInfo.invoke().then((itemData: ItemData[]) => {
1 Reply
Nightmare
NightmareOP2w ago
whole error
17:54:47.618 Unhandled Promise rejection:

-- Promise.Error(ExecutionError) --
tables cannot be cyclic
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.event.createEvent:49 function fireServer
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.function.createFunctionSender:89 function invokeServer
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.functions.createClientMethod:15 function invokeWithTimeout
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.functions.createClientMethod:9 function invoke
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:79 function pickItem
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:56
ReplicatedStorage.rbxts_include.Promise:172 function runExecutor
ReplicatedStorage.rbxts_include.Promise:181

Promise created at:

Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:34 function DropOrEquipPressed
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:25


Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:34 function DropOrEquipPressed
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:25
17:54:47.618 Unhandled Promise rejection:

-- Promise.Error(ExecutionError) --
tables cannot be cyclic
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.event.createEvent:49 function fireServer
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.function.createFunctionSender:89 function invokeServer
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.functions.createClientMethod:15 function invokeWithTimeout
ReplicatedStorage.rbxts_include.node_modules.@flamework.networking.out.functions.createClientMethod:9 function invoke
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:79 function pickItem
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:56
ReplicatedStorage.rbxts_include.Promise:172 function runExecutor
ReplicatedStorage.rbxts_include.Promise:181

Promise created at:

Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:34 function DropOrEquipPressed
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:25


Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:34 function DropOrEquipPressed
Players.Nightmare_pogg.PlayerScripts.TS.logic.InventoryHandler:25
uh maybe it have something to do with remote events when I look on it but like
import { Functions } from "server/network";
import { Item } from "shared/types/items/Item";
import { ItemData } from "shared/types/items/Item";
import { getInventoryFromID } from "server/logic/inventory/inventoryLogic";
import { Inventory } from "server/logic/inventory/inventoryDatabase";

Functions.pickUp.setCallback(async (requestingPlayer, slot, itemClass: new () => Item): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.pickItem(slot, itemClass);
}
return false;
});

Functions.dropItem.setCallback(async (requestingPlayer, slot): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.dropItem(slot);
}
return false;
});

Functions.useItem.setCallback(async (requestingPlayer, slot): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.useItem(slot);
}
return false;
});

Functions.getItemsInfo.setCallback(async (requestingPlayer): Promise<ItemData[]> => {
print("wa wa");
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
print("wa");
return playerInventory.getSlotItems();
}
return [];
});
import { Functions } from "server/network";
import { Item } from "shared/types/items/Item";
import { ItemData } from "shared/types/items/Item";
import { getInventoryFromID } from "server/logic/inventory/inventoryLogic";
import { Inventory } from "server/logic/inventory/inventoryDatabase";

Functions.pickUp.setCallback(async (requestingPlayer, slot, itemClass: new () => Item): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.pickItem(slot, itemClass);
}
return false;
});

Functions.dropItem.setCallback(async (requestingPlayer, slot): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.dropItem(slot);
}
return false;
});

Functions.useItem.setCallback(async (requestingPlayer, slot): Promise<boolean> => {
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
return playerInventory.useItem(slot);
}
return false;
});

Functions.getItemsInfo.setCallback(async (requestingPlayer): Promise<ItemData[]> => {
print("wa wa");
const playerID: number = requestingPlayer.UserId;
const playerInventory: Inventory | undefined = getInventoryFromID(playerID);
if (playerInventory) {
print("wa");
return playerInventory.getSlotItems();
}
return [];
});
this is whole server side of handling it fixed -> I am not sending class but just it's ID

Did you find this page helpful?