I have been having issues with people crashing the server anytime they want to by freezing themselves with lots of motors and then leaving the game, But i have no idea why this happens.
The server only crashes ingame but not in studio.
The network owner is set correctly.
The playerremoving event does not fire ingame once the server freezes.
local function changenetworkowner()
if Player then
for i,h in pairs(NewAircraft:GetDescendants()) do
if h:IsA("BasePart") then
pcall(function()
h:SetNetworkOwnershipAuto(Player)
h:SetNetworkOwner(Player)
end)
end
end
else
NewAircraft:Destroy()
end
end
MiscFunctions.UnanchorModel(NewAircraft)
for i,Part in pairs(NewAircraft:GetDescendants() do
if Part:IsA("BasePart") then
local succes1,message1 = pcall(function()
Part:SetNetworkOwnershipAuto(Player)
Part:SetNetworkOwner(Player)
end)
if message1 then
Part.Changed:connect(function() -- for anchored blocks which can be anchored or unanchored
local Success5,Message5 = pcall(function()
if Part:GetNetworkOwner() ~= Player then
changenetworkowner()
end
end)
if Message5 and string.match(string.lower(Message5),"anchored") then
changenetworkowner()
end
end)
end
end
end
This is the part where it changes the network owner which might affect it, But im not sure though.
Perhaps it is because of the Destroy since there are so many parts, try going through each part individually and destroying it but wait every 2-10 iterations.
for index, Part in pairs(NewAircraft:GetChildren()) do
Part:Destroy();
if (index % 5) == 0 then wait(.1) end
end
I removed NewAircraft:Destroy() and it the server ingame still crashed, But i have no idea why its only the ingame version, There is no lag at all in studio. I will check right now if changing NewAircraft:Destroy() to that will fix this.
When you SetNetworkOwnership it will stay that way, setting SetNetworkOwnershipAuto will make the server decide who will calculate the Basepart’s physic.
There are no Errors because you warp it in a pcall, there might be an Error, you don’t need to warp it in a pcall anyways.