Crashing player causes server to crash ingame but not in studio?

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.



image

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.

1 Like

Could you show some code at all?

I have no idea what could have an effect on this, What code would you want to see?

Variables associated to the algorithm which places down the items?
Something to work with I guess.

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.

This did not fix it.

What happens when a player leaves the game in your game / when a plot is removed from the game?
What checks/events fire through the entire procedure?

SetNetworkOwnershipAuto does need an argument,

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.

V isn’t defined, assuming you meant to use Part instead of v

Changenetworkowner function doesn’t have to run through every descendant everytime a part isn’t owned by a player

Oh sorry i forgot to change that part. I fixed the script now.

I changed every line of code in any script with the script you posted.
This did not help sadly. Do you have any other ideas on what could cause this?

I tried testing it without a plot and the server did not crash.

Mark this as resolved considering our discussion <3

1 Like

The issue is fixed. Somehow by setasyncing while the flightaircraft was spawned in caused the server to crash