This is what i have:
if part.ForceField == false then
The code dosen't seem to work sometimes, hopefully someone could help.
This is what i have:
if part.ForceField == false then
The code dosen't seem to work sometimes, hopefully someone could help.
It doesn't work because you're comparing an object to a boolean, which will always be false. An object is never going to be false, though they are truthy (not false or nil).
Using the :FindFirstChild() function you can do this. It will return nil if the child wasn't found.
if part:FindFirstChild("ForceField") then
-- Do something if the force field IS found
end
if not part:FindFirstChild("ForceField") then
-- Do something if the force field is NOT found
end
######Hopefully this answered your question, and if it did, then don't forget to hit that accept button. If you have any more questions, then feel free to leave them down in the comments.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Thank you, it works!
You could just write else, to cut all the lining