Hello there… I am making a big module and I am cloning parts into a viewport, how would I check if those parts are the same?
You could have a specific color/value in the part/specific name, then check if it is the same.
That wouldn’t work, I need to check if they are identically the same.
You would then have to go through all the options in both parts and checking if they’re equal.
When you say identical, do you mean all properties are equal, or both cloned from the same original part? Because if you want them to be cloned from the same original part, putting a value inside the original part and checking both parts for it WOULD work in theory. Otherwise, you’re just going to have to check as many properties as you can manually.
Cloned from an original part. The positions are different. I am using a viewport, so I need to check if a part is cloned etc.
And just to clarify, I am asking this because I am trying to find the descendant that’s been cloned.
Put an ObjectValue inside each clone, and set the value to the item that was cloned. You can call it “Original” for example, and then check if Part1.Original.Value == Part2.Original.Value.
You could also probably have a table with the properties to check, then on a for loop check if the x property of part 1 is equal to part 2’s property.
That’s what I am doing, but it’s a descendant which makes it difficult.
If you want to find all parts that were cloned from that parent, then you can do
local function FindClones(Original)
local Clones = {}
for i,v in pairs(workspace:GetDescendants()) do
if v:FindFirstChild("Original") then
if v.Original.Value == Original then
table.insert(Clones, v)
end
end
return clones
end
This would return a table with all the clones in it
That’s not what I mean at all, I’ve already done that.
I’m not sure what you’re trying to achieve then. A descendant in Roblox is any item that is a child of something, or a child of a child, or a child of a child of a child etc. An ancestor is the direct opposite.
What sort of arguments do you need to pass, and information do you need returned?
for i, descendant in pairs(object.Descendants) do
for i, part in pairs(thing:Descendants()) do
if part == descendant.Object then
descendant.Cloned = descendant.Object.Name
print(descendant.Cloned)
end
end
end
I have a structure, but i don’t know how to check if it’s equal to.
In this code:
for i, descendant in pairs(object.Descendants) do
for i, part in pairs(thing:Descendants()) do
if part == descendant.Object then
descendant.Cloned = descendant.Object.Name
print(descendant.Cloned)
end
end
end
I need to check if the part in the original object is equal to the cloned one.
Like some of the replies above, you can compare the properties of the objects to the original that would not be changed: Colors, Size…
Or, I think you can create ObjectValues and put them in a folder that you would know consists of objects that are like the original.
I guess I will just check if the position is almost identical.
I just thought there would another easier way, as I am guessing roblox compares addresses in data of the cloned objects.
If only there would just be a :GetProperties() method.