I have a bunch of unanchored parts in my workspace because they are animated. I’m running a loop to get all my workspace descendants and checking if they are parts and are unanchored:
for index, eachDescendant in pairs(game.Workspace:GetDescendants()) do
if eachDescendant:IsA("BasePart") then
if not eachDescendant.Anchored then
local canSet,errorReason = eachDescendant:CanSetNetworkOwnership()
if canSet then
print(eachDescendant)
eachDescendant:SetNetworkOwner(nil)
else
print("cannot change ", eachDescendant, " because ", errorReason)
end
end
end
end
I’m wondering if anyone has a more efficient method around this as I have to loop through all my workspace descendants everytime my server starts.
You can make a folder/table and put models that have the unanchored parts, so the for loop doesn’t have to check all workspace’s descendants, only the folder’s descendants or table’s values (Avoiding checking unnecessary objects and parts)
Yes actually thats a wonderful Idea and it results in a much smoother gameplay experience. Why would you need to override that and preemptively set everything to the server?
I fail to see a situation where this code would need to be used. I believe there may be a much better solution to this problem entirely.