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

How do you filter out a specific set of objects when selecting a large group of them?

Asked by 4 years ago

Hi, this is a concept question. The title may be hard to understand, but it is self-explanatory. I have a mirror that generates models on the other side of itself, and these models are meant to, obviously, replicate the world on the other side of the mirror. This said mirror generates everything inside of the workspace and inverts it onto the other side of the mirror. To do this, it selects all bricks in the workspace (including character bricks) to copy and invert. So, I was wondering, how would I exclude a specific set of bricks from this mirror selection? As in, I want a whole model to not be selected and copied by the mirror. So, how would I exclude this specific model from the mirror's whole workspace selection? Is there a specific property I can use or a chain of statements?

--Here's the code, in case you need it to figure out a solution. It relies on a few other modules but this is the main block of code and the one where hopefully I can insert the model
--exclusion statement
local player = game:GetService("Players").LocalPlayer
local character; repeat wait() character = player.Character until character
local camera = game:GetService("Workspace").CurrentCamera

local rs = game:GetService("RunService").RenderStepped
local reflections = require(script:WaitForChild("reflections"))

local mirrors = game:GetService("Workspace"):WaitForChild("Mirror model")

rs:connect(function()
    reflections:clearCharacters()
    local characters = {}
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        table.insert(characters, player.Character)
    end
    for _, mirror in pairs(mirrors:GetChildren()) do
        if mirror:IsA("BasePart") then
            reflections:drawWorld(mirror, game:GetService("Workspace"), {mirrors, unpack(characters)})
            reflections:drawCharacters(characters, mirror)
        end
    end
end)

1 answer

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

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I've added an extra part to the if statement that checks the parent of the part, if it's parent isn't in the excluded model then the statement passes through.

 for _, mirror in pairs(mirrors:GetChildren()) do
        if mirror:IsA("BasePart") and mirror.Parent ~= excludedModel then -- changed here
            reflections:drawWorld(mirror, game:GetService("Workspace"), {mirrors, unpack(characters)})
            reflections:drawCharacters(characters, mirror)
        end
    end
Ad

Answer this question