While you can do this to set properties without errors:
-- This is a random function I made that has relevancy in the Topic
function makeInstance(class, data)
local item = Instance.new(class) -- a new Item
for i,v in data do -- iterates through Data
pcall(function() -- so no errors occur
item[i] = v -- applies data
end)
end
return item -- returns item
end
local obj = makeInstance("Part", {Parent = workspace, Position = Vector3.one})
I was wondering on how would I Skip a Property if it does not exist, as normally when you try it will say
... is not a valid member of ...
and I understand about using the pcall
in the function to check for success and stuff, but I wanted to check before the pcall
even fires, so the code can just skip before it attempts to apply a property.
So how would I do this without causing an error?