local part = Instance.new("Part") part.CanCollide = true part.Anchored = true part.BrickColor = BrickColor.new("Really red") part.Material = "Neon" part.Parent = game.Workspace part.Size = Vector3.new(10,10,10) part.CFrame = game.Workspace.Spot.CFrame for i = 1,10 do wait(1) part.Size = part.Size + Vector3.new(1,1,1) end part.Touched:connect(function(Part) -- rest of code that is useless
Basically lets say the loop is at 5, if it is touched will it still detect it and and do the part.Touched function?
Yes that would be possible, granted that you use a GetChildren
or GetDescendants
table, as the value portion of both those arrays are objects, and assuming those objects are base parts (parts, truss parts, mesh parts, etc.)
Which means you can do the following:
local things = workspace:GetChildren() for _,part in pairs(things) do if part:IsA("BasePart") then part.Touched:Connect(function() ... end) end end
What I used here, in case you didn't know , is a generic for loop, which instead of being formatted like :
for iter = start,finish, increment do ... --print(iter) end
and is instead is formatted like
for key, value in pairs(Table) do--next, and ipairs() also work ... --print(key,value) end