✓ Accepted answer
Well I would put the loop in another thread and use the Wait function of the event so that when the basepart touches another basepart it will change the value of a variable to something else.
Samples:
Running a while loop with code after to represent that while loops yield the current thread:
while true do
wait(1)
end
print('wow potato')
Running the same while loop on a different thread:
spawn(function()
while true do
wait(1)
end
end)
print('wow potato')
Repeating adding a number until the basepart is touched using Wait
local part = part
local IsTouched = false
spawn(function()
while not IsTouched do
part.Size = part.Size + Vector3.new(1,1,1)
end
end)
part.Touched:Wait()
IsTouched = true
Using Connect to stop looping size (You do not need to add another thread):
local part = part
local IsTouched = false
part.Touched:Connect(function()
IsTouched = true
end)
while not IsTouched do
part.Size = part.Size + Vector3.new(1,1,1)
end
2 comments
Check if the part is a humanoid or not
not a humanoid