How to not clone a part into a part that already has a part cloned on it?

I know the title may be confusing but let me break it down. I’m currently working on a coin system where I have these parts where I spawn coins onto I have these all across the map. I have cloning the coin onto these parts down but I’m stuck on not cloning the coins onto the parts that already have coins cloned on them. Any ideas on how would I do this?

You can create and reference a table when creating/cloning coins.

--Goes with your defined variables
local AlreadyClonedParts = {} --This creates a table named AlreadyClonedParts

--Goes before you create the coin as a conditional
if not table.find(AlreadyClonedParts,ThePartWhereItsBeingClonedTo) and ThePartWhereItsBeingClonedTo then --This makes sure that you haven't created a coin at this part and that ThePartWhereItsBeingClonedTo exists before proceeding.

--Goes with when you create/clone a coin
table.insert(AlreadyClonedParts,ThePartWhereItsBeingClonedTo) --This records that a coin was created/cloned at this part.
1 Like

If “coin” is a uniquely named child to thing you could call thing:FindFirstChild(“coin”) first. If it returns nil there is no “coin” inside of the thing

1 Like

Just implemented your method and it works very well. I don’t know how I didn’t thought of this before, thank you!

1 Like