Hi, I have this loop, i wanted to check if one of the folder’s part is touching something but it doesn’t print nothing
while wait() do
for _,room in pairs(workspace:GetChildren()) do
if room.Name == "CRoom" then
for _,checkBlock in pairs(room:WaitForChild("ChecksBlocks"):GetChildren()) do
for i,v in pairs(checkBlock:GetTouchingParts()) do
print(v)
for _,checkValue in pairs(room:WaitForChild("ChecksValues"):GetChildren()) do
if checkValue.Name == checkBlock then
checkValue.Value = true
end
end
end
end
end
end
end
These 2 folders are contained in a Model, i want to check if one of the parts in CheckBlocks folder is touched. When touched, change the value to true to the value in the CheckValues folder with the same name.
i made this with another method but the result is the same
while wait() do
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "CRoom" then
local CheckBlocks = v:WaitForChild("CheckBlocks")
local CheckValues = v:WaitForChild("CheckValues")
for i,v in pairs(CheckBlocks:GetChildren()) do
v.Touched:Connect(function()
print("touched")
CheckValues:FindFirstChild(v.Name).Value = true
end)
end
end
end
end
That’s the problem. I tried your script and it doesn’t work only if you set CanCollide to false.
To get it to work I used SpatialQuerry.
Try to change this
To this:
for i,v in pairs(workspace:GetPartsInPart(checkBlock)) do
while wait() do
for i,v in pairs(workspace:GetChildren()) do
if v.Name == "CRoom" then
local CheckBlocks = v:WaitForChild("CheckBlocks")
local CheckValues = v:WaitForChild("CheckValues")
for i,v in pairs(CheckBlocks:GetChildren()) do
v.Touched:Connect(function()
print("touched")
CheckValues:FindFirstChild(v.Name).Value = true
end)
end
end
end
end