I need a code to continuously check if a certain condition has been met. I tried using if statements, but I noticed they only check for it when the script is run, or they are called in a function. I tried using a while loop, but, That was catastrophic. It almost crashed studio. I don't even know if a for loop would work because when I typed for #script.Parent.Detector1:GetTouchingParts() == 3 do, the hashtag was underlined red. I am looking for a way to run the function only once, and only when the certain condition is met. Here is the part I need help with:
if script.Parent.Detector1:GetTouchingParts() == 3 then -- My dumb attempt at using an if statement ? --
print("touching three parts")
end
Help is greatly appreciated. Thanks!

7 comments
Please accept the answer to mark it answered, to get us both rep, and I don't like leeches.
Thank you so much I was clueless about this i couldnt even make my own loop anyways hope you have an awesome day or night
No problem, have a great one!
Waits prevent crashing in constant loops, might want to keep that in mind for the future. lol
;p
Avoid using "wait"s for things that change that fire a certain event. Use "script.Parent.Detector1.Touched:Wait()"
I honestly really hate touched