Network ownership forced to server is being set back to nearest client

Hi all,
I have a skiing game that relies heavily on parts being set on the server, but for some reason, they keep getting set back to the client when near the player. I loop through the entire model to ensure they are set to the server, but it seems it still does not work. I have reverted to the following code which is awful because I am running the function every heartbeat which is obviously is not good. Is this a roblox bug or am I doing something wrong? https://gyazo.com/22edf63becfb1df724c22ac6ea5e42ca (watch the output)

local RS = game:GetService("RunService")
local liftdirectory = game.Workspace:WaitForChild("LineRopes")
local parts = {}

function grabParts()
    for i,v in pairs(script.Parent:GetDescendants()) do
        if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("MeshPart") or v:IsA("Seat") then
            table.insert(parts,v)
        end
    end
end

wait(2)
grabParts()

function SetNetworkOwner()
    for i,v in pairs(parts) do
        if not v.Anchored then
            pcall(function() if v:GetNetworkOwner() ~= nil then print(v:GetNetworkOwner()) v:SetNetworkOwner(nil) print(v.Name) print("Set to nil") end end)
        end
    end
end

SetNetworkOwner()

RS.Heartbeat:Connect(function()
    if liftdirectory.CurrentSpeed.Value ~= 0 then
        SetNetworkOwner()
    end
end)
1 Like

Is this a localscript or a serverscript?

Yeah, Is this a local script or a serverscript? it can make a difference.

Server script, of course. Could it be because not all parts are loaded in when I grab them 2 seconds after the script loads?

1 Like

U didn’t have to have all those or operators checking if it is a BasePart, u only need Instance:IsA("BasePart") since all parts inherit from BasePart

2 Likes

Yes, I realized that but that makes no difference. It is just redundant so it wont negatively affect it.

When doing SetNetworkOwner(nil), the server is controlling it. It shouldn’t change automatically unless you do it (?)

Doesn’t make sense, unless this page does (I did not read it fully).

That is why I am thinking that I should wait more before grabbing parts. I think I might have it check every 5 seconds until the # of parts does not change. Then end it

I don’t see anything wrong in the Script. Could be a Roblox bug.

Yes I double checked and it grabs every part in the model properly, so I am thinking it is a bug.

Screenshot by Lightshot (30 charssssssss)

Does the Pcall return any Errors?

Also is everything unanchored as @Syclya said

image
Yes it is saying something is anchored even though I am positive everything is not anchored (the parts are moving so clearly not anchored)

If parts are moving that doesn’t mean its anchored. Is there any welds in the model?

Try this.

local Location = game:GetService("Workspace").Folder:GetChildren() -- wherever they are

for i = 1, #Location do
	Location[i].Anchored = false
end

Just to make sure ( . . . )

Try printing part:IsGrounded() to see if the part is connected to anything that is Anchored

Nope it says false. Whenever I approach the model the heartbeat loop says some random part is owned by me and so it forces it back to server. I do not want to have to run a heartbeat loop because it is expensive so I don’t know why it is reverting

Everything is unanchored now. It was a lone model but that did not affect anything so something else is causing it. Maybe a roblox bug?

Submit a bug report here if you believe so: Support

Ok it appears to happen when I sit on the model, so it is fine that I set it to server, but when I get up from the seat every few seconds it still says a lone part is opened by my character and resets it to server.