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

How to make search the object have spesific part or script in the Workspace?

Asked by 4 years ago

Im trying to make a script that searches all around the pivot point and tag the objects that has "collectable" scrip in it. How can i make the script search for "Collectable" script in the objects?

0
Please provide us with your attempt even if the code is not functional. User#5423 17 — 4y

1 answer

Log in to vote
0
Answered by
Alphexus 498 Moderation Voter
4 years ago

If I understood your question, you should be using a for loop. Loop through Workspace and see if it has any children called Collectable. I made a function that will return all collectable items in a table.

local function GetCollectableItems()
    local items = {}
    for i,v in pairs(workspace:GetChildren()) do
        local Collectable = v:FindFirstChild("collectable")
        if Collectable then
            table.insert(items, v)
        end
    end
    return items
end
0
Thank you So much! emay0660 13 — 4y
0
no problem Alphexus 498 — 4y
Ad

Answer this question