im trying to use a table to emulate a model in workspace
this table is a clone of the model
inside the table is parts, some parts have an objectvalue inside them and others dont
here’s what a part with an objectvalue looks like in the original model
im trying to destroy() an objectvalue inside a part the in table and it nils saying value doesnt exist however, it exists and i can find it with print(part.Value)
local currentSquareOn = UtilityChess:FindSquareByPiece(clonedTable, Piece)
print(currentSquareOn.Value)
00:00:00.00 Value - Client - ReplicatedChess:160 (no error)
currentSquareOn.Value:Destroy()
00:00:00.00 ReplicatedStorage.ReplicatedChess:160: attempt to index nil with ‘Value’ - Client - ReplicatedChess:160
is there anyway to remove the Value object inside the table?
Reread the issue. Are you maybe accidentally setting currentSquareOn to something else before currentSquareOn.Value:Destroy()?
Try an if statement:
local currentSquareOn = UtilityChess:FindSquareByPiece(clonedTable, Piece)
if currentSquareOn and currentSquareOn:FindFirstChild("Value") then
currentSquareOn.Value:Destroy()
end