So the original thread is kind of old, and I wanted to posy my suggestion:
To check if an object exists, use if _:FindFirstChild("object")~= nil then
where _ is your full name and object is your name's child.
~= nil is pointless in this situation, and it's explained poorly.
@TheAlphaStigma I'm not sure actually; are you suggesting that there is no difference and using the former is better?
~= nil isn't necessary; it's the same as saying
if Condition then.
-- Example using ~= nil local Part = Workspace:FindFirstChild('Part') if Part ~= nil then print('Found part!') end -- Example w/o ~= nil local Part = Workspace:FindFirstChild('Part') if Part then print('Found part!') end
I originally posted the link because I wanted to show that
~= nil isn't necessary.
But meh, to each their own.
@TheAlphaStigma Did you mean
not Part returns
false if the part exists, and
true if it does not.
Another thing involving Conditional logic
Instead of putting two bits of code in an if then statement, where you are to check the truthiness of two statements and assign it to something, like so...
local var if statement1 then var = statement1 elseif statement2 var = statement2 end
...You could compact it into one line:
local var = statement1 or statement2
Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.