diff --git a/src/Common/useDescendants.luau b/src/Common/useDescendants.luau index b0d8dd17..60d5458d 100644 --- a/src/Common/useDescendants.luau +++ b/src/Common/useDescendants.luau @@ -1,6 +1,13 @@ local React = require("@pkg/React") local Sift = require("@pkg/Sift") +local function hasPermission(instance: Instance) + local success = pcall(function() + return instance.Name + end) + return success +end + local function useDescendants(parent: Instance, predicate: (descendant: Instance) -> boolean): { Instance } local descendants: { Instance }, setDescendants = React.useState({}) @@ -8,6 +15,10 @@ local function useDescendants(parent: Instance, predicate: (descendant: Instance setDescendants(function(prev) local exists = table.find(prev, descendant) + if not hasPermission(descendant) then + return prev + end + if predicate(descendant) then if exists then -- Force a re-render. Nothing about the state changed, but the @@ -41,6 +52,10 @@ local function useDescendants(parent: Instance, predicate: (descendant: Instance -- Listen for name changes and update the list of descendants for _, descendant in parent:GetDescendants() do + if not hasPermission(descendant) then + continue + end + table.insert( connections, descendant:GetPropertyChangedSignal("Name"):Connect(function() diff --git a/wally.toml b/wally.toml index e6900a4e..ed032e02 100644 --- a/wally.toml +++ b/wally.toml @@ -1,6 +1,6 @@ [package] name = "flipbook-labs/flipbook" -version = "1.5.0" +version = "1.5.1" license = "MIT" registry = "https://github.com/UpliftGames/wally-index" realm = "shared"