local inputPropertyReturnValue:{[string]:any} = {}
local propertiesTable = {
["cylinder"] = {"Color","Visible"},
["displayPart"] = {},
["joint"] = {"Position","Orientation","Visible"},
["part"] = {"Position","Orientation","Size","Color","Material","Reflectance","Transparency"}
}
local function inputObjectReturnObjectTypeString(object):string
if inputCylinderReturnArrayOfTwoJoints[object] ~= nil then return "cylinder"
elseif displayPartReturnsArrayOfTwoBlocks[object] ~= nil then return "displayPart"
elseif inputJointReturnJoint[object] ~= nil then return "joint"
else return "part" end
end
local function hasProperty(object, propertyName):boolean
local success, _ = pcall(function()
object[propertyName] = object[propertyName]
end)
return success
end
local function compare(new, old)
local result = {}
local equal = false
if typeof(new) == "Vector3" then
for _, xyz in {"X", "Y", "Z"} do
if old[xyz] ~= "" and new[xyz] == old[xyz] then
result[xyz] = new[xyz]
equal = true
else
result[xyz] = ""
end
end
else
if old ~= "" and new == old then
result = new
equal = true
else
result = ""
end
end
return result, equal
end
function module.UpdateUIAdding(lastSelectedObject)
for _, property in propertiesTable[inputObjectReturnObjectTypeString(lastSelectedObject)] do -- checks if 'lastSelectedObject' is a cylinder, displayPart, joint, or part, and then goes through the properties in the table for that object type
if inputPropertyReturnValue[property] == "" then
continue
end
local objectHasPropertyOrNil = nil
if hasProperty(lastSelectedObject, property) == true then -- checks for the property or attribute of the last selected object
objectHasPropertyOrNil = lastSelectedObject[property]
elseif lastSelectedObject:GetAttribute(property) ~= nil then
objectHasPropertyOrNil = lastSelectedObject:GetAttribute(property)
end
if objectHasPropertyOrNil ~= nil then -- if the property of attribute of the last selected object is found, then
if inputPropertyReturnValue[property] == nil then -- if the table doesn't have the property (when the first/initial part is selected, such as from 0 to 1 number of parts selected, the table was blank before)
if typeof(objectHasPropertyOrNil) == "Vector3" then
inputPropertyReturnValue[property] = { ["X"] = objectHasPropertyOrNil.X , ["Y"] = objectHasPropertyOrNil.Y , ["Z"] = objectHasPropertyOrNil.Z }
else
inputPropertyReturnValue[property] = objectHasPropertyOrNil
end
else -- if the table already has the property (when the number of parts selected (of the same type) is more than 1, the table already has the properties from the first part)
inputPropertyReturnValue[property] = compare(objectHasPropertyOrNil, inputPropertyReturnValue[property])
end
end
end
end
Thanks in advance!!!