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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.
0
Ooohh.. It returned the parts not their names. Im so stupid. Anyways thank you. That fixed it(: Herobrinekid1 31 — 3y
Ad

Answer this question