Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

trying to get a nil value when using GetTouchingParts()?

Asked by 5 years ago
script.Parent.Touched:Connect(function()end)



while true do

wait(1)

local part = script.Parent

local bounds = part:GetTouchingParts()

for _, p in next, bounds do



if p == nil then

print("nothing")

end

end

end

this script gets the parts that are inside it using GetTouchingParts() I was trying to get it to output nil when there is nothing touching but it wont throw an error or say nil when there is nothing inside it. this is a problem because I need to be able to do something else when a specific part/model that "was" touching is now gone. is there a way to make this as easy as using FindFirstChild() to get a nil value?(findfirstchild didnt work when I combined it btw)

0
What is it printing then if it's not printing nil? davidgingerich 603 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

delete the end) after connect(function() and put a ) at the last line ur not connecting the function right now

here is what i mean u should do

script.Parent.Touched:Connect(function()



while true do

wait(1)

local part = script.Parent

local bounds = part:GetTouchingParts()

for _, p in next, bounds do



if p == nil then

print("nothing")

end

end

end)
0
to answer both comments within the last 6 hours, the script did not print anything when ran. and also:https://devforum.roblox.com/t/simple-trick-to-make-gettouchingparts-work-with-non-cancollide-parts/177450 this is why I have gettouchingparts set u pthe way it is as it will not work without it. mantorok4866 201 — 5y
Ad

Answer this question