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)
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
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
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
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.