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

How do i set all parts NetworkOwner to nil in the workspace?

Asked by 4 years ago

I want to make a script that sets NetworkOwner to nil for all parts in workspace but it gives this error: Network Ownership API cannot be called on Anchored parts or parts welded to Anchored parts. So i tried to fix it but it still gives a error. The Code:

01function CheckWelds(Part)
02local Found = false
03for i,v in pairs(Part:GetDescendants()) do
04if Found == false then
05if v.ClassName == "Weld" then
06Found = true
07return "Found"
08end
09end
10end
11if Found == false then
12wait()
13return "None"
14end
15end
View all 27 lines...

https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab

2 answers

Log in to vote
0
Answered by 4 years ago

I fixed it with a pcall function. ::::))))))

1pcall(function()
2v:SetNetworkOwner(nil)
3end)
0
A pcall will stop your script from returning the error, it'll still error inside the pcall, so it still won't work. Befogs 113 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Because a part doesn't have a weld as a child, doesn't mean it isn't welded. You can check if its welded to anything with #Part:GetJoints(), if its 0 that means there are no welds attached. So your whole code is just this now:

1for _,v in pairs(workspace:GetDescendants()) do
2    if v:IsA("BasePart") then
3        if not v.Anchored and #v:GetJoints() == 0 then
4            v:SetNetworkOwner(nil)
5        end
6    end
7end

Answer this question