Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

"table.find" not working on GetTouchingParts()?

So. Basically im trying to find a value / string inside the table that GetTouchingParts() returns. But for some reaon its not working.. Heres my code atm:

while true do
		local TABLE = Part:GetTouchingParts()
		if table.find(TABLE, "Stop") then
			print("Stopped loop")
			break
		end
		wait()
	end

1 answer

✓ Accepted answer

If I understand what you mean you're trying to detect parts that are touching Part specifically a part called 'Stop'. Just put a for loop inside of a repeat loop.

local part = workspace.Part -- The part that you're trying to find which is touching it.
local stopPart = workspace.Stop -- The stop part
local found = false --Check whether if it was found

repeat
    local TABLE = part:GetTouchingParts()

    for index, value in pairs(TABLE) do
        if value.Name == "Stop" then
            found = true
        end
    end
    wait()
until found == true -- this works like an if statement.

1 comment

0

Ooohh.. It returned the parts not their names. Im so stupid. Anyways thank you. That fixed it(:

This discussion is preserved as it was. New answers, comments, and votes are closed.