SERVER CRASH [Internal/RbxThread]

Read up on this and it doesnt work for R15 yet unfortunately

Fair point, but you can spawn R15 rigs instead via some simple changes. Alternatively would you care to share the relevant npc spawn & control code so we can review it.

1 Like
task.spawn(function()
	while not workspace:GetAttribute("PathfindCancel") do
		task.wait((#Battles - 1)*0.1 + 0.2)
		ActiveRequest = ActiveRequest
		ComputationQueue = ComputationQueue
		if #Battles == 0 then continue end
		
		local EarliestID
		local EarliestInfo
		local PreviousTime
		for ID,Info in pairs(ComputationQueue) do
			if not (Info.Request and Info.QueueTime) then continue end
			task.wait(0.1)
			if not PreviousTime then
				EarliestID = ID
				EarliestInfo = Info
				PreviousTime = Info.QueueTime
			elseif (tick() - PreviousTime) < (tick() - Info.QueueTime) then
				EarliestID = ID
				EarliestInfo = Info
				PreviousTime = Info.QueueTime
			end

		end

		if EarliestID and ComputationQueue[EarliestID] and (tick() - LastCompute) >= 2 then
			warn("Computing "..(tick() - LastCompute))
			LastCompute = tick()
			local Index = ComputationQueue[EarliestID] or {}
			local Path = PathfindingService:CreatePath(Index.Params or {})
			Path:ComputeAsync(Index.StartPos,Index.GoalPos)
			if Path.Status == Enum.PathStatus.Success then
				ComputationQueue[EarliestID] = {Path=Path}
			else
				if Path then Path:Destroy() end
				local Attempts = Index.Attempts or 0
				Attempts += 1
				if Attempts > 2 then
					ComputationQueue[EarliestID].Request = nil
				elseif ComputationQueue[EarliestID] and ComputationQueue[EarliestID].Attempts then
					ComputationQueue[EarliestID].Attempts = Attempts
				end			
			end			
		end


	end
end)

This is the pathfinding code snippet

This is the console print the last thing printed before the crash is "Computing (The time since last computeasync) Screenshot by Lightshot

		local SpawnCF = Data.SpawnCF
		local CHSpawn = SpawnFolder:GetChildren()[math.random(1,#SpawnFolder:GetChildren())]
		if (CHSpawn or SpawnCF) then
			local Model
			if IsPlayer and SquadCount == 1 and (Controller and Controller.Parent)  then
				local BattleHUD = Assets.GUI.Battle.BattleHUD:Clone()
				BattleHUD.Parent = Controller.PlayerGui
			end

			Model = AceData.ModelRef or Data.Model
			if not Model then
				local FolderIndex = ReplicatedStorage.Assets.CharacterModels.Skins
				Model = AceData.ActiveSkin and FolderIndex and FolderIndex:FindFirstChild(AceData.ActiveSkin) or ReplicatedStorage.Assets.CharacterModels:FindFirstChild(AceName)
				if not Model then
					warn("No model found for "..AceName)
					AceFolder:Destroy()
					return
				end
				Model = Model:Clone()
			end
			if not Model then
				Model = Assets.ReferenceRig:Clone()
			end

			local HUM = Model:FindFirstChild("Humanoid")
			HUM.RequiresNeck = false
			HUM.AutoJumpEnabled = false

			if SquadCount == 1 and not Data.SpawnCF then
				StartPos[Team] = (CHSpawn.CFrame)
				SpawnCF = StartPos[Team]
				table.insert(SpawnPositions[Team], SquadCount, SpawnCF)

				local FullCircle = (2 * math.pi)
				local Dist = 12
				for i = 2, MaxSquad do
					local Angle = -(i * (FullCircle/MaxSquad))

					local x = math.cos(Angle) * Dist
					local z = math.sin(Angle) * Dist

					local AdditionalSpawnCF = StartPos[Team] * CFrame.new(x, 0, z)
					table.insert(SpawnPositions[Team], i, AdditionalSpawnCF)
				end
			elseif not Data.SpawnCF then
				local TeamSpawns = SpawnPositions[Team]
				SpawnCF = TeamSpawns[SquadCount]
			end

			local FinalSpawnCF = SpawnCF or StartPos[Team] or (CHSpawn.CFrame)


			Model.PrimaryPart.CFrame = FinalSpawnCF--*CFrame.new(0,-2,0)
			local BG = Instance.new("BodyGyro",Model.PrimaryPart)
			BG.CFrame = FinalSpawnCF
			BG.MaxTorque = Vector3.new(1e8,1e8,1e8)
			game.Debris:AddItem(BG,1.5)
			Model.Name = "Model"
			Model.Parent = AceFolder

			local Container
			if not Data.Model then -- Creates a new container and makes a state connection if its a brand new model
				Container = StateHandler:GetContainer(HUM) or StateHandler:CreateContainer(HUM)
				local StateConnection = Container.StateAdded.Event:Connect(StatusAdded)
				local StateConnection2 = Container.StateRemoved.Event:Connect(StatusRemoved)
				table.insert(BattleConnections,StateConnection)
				table.insert(BattleConnections,StateConnection2)

				local StateConnected3 = HUM.StateChanged:Connect(function()
					local NewState = HUM:GetState()
					if table.find(BadStates,NewState) then
						HUM:ChangeState(Enum.HumanoidStateType.GettingUp)
					end
				end)
				table.insert(BattleConnections,StateConnected3)
			else
				Container = StateHandler:GetContainer(HUM) or StateHandler:CreateContainer(HUM)
			end

			if not table.find(ActiveAces,AceFolder) then
				table.insert(ActiveAces, AceFolder)		
			end

Alright I believed I resolved the issue: In my game battles are created further and further away from the origin so eventually computing a path 342432342342334 studs away gets a bit hectic for the pathfinding causing the server to crash

1 Like

Goof to hear that you have fixed it.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.