Invalid argument #1 to 'new' (Vector3 expected, got nil)

local player = game:GetService('Players').LocalPlayer
local mouse = player:GetMouse()
local uis = game:GetService("UserInputService")

local isDrawing = false
local startPos
local endPos

mouse.Button1Down:Connect(function()
	if mouse.Target and mouse.Target:IsA("Part") then
		startPos = mouse.Hit.Position
		isDrawing = true
	end
end)

mouse.Move:Connect(function()
	if isDrawing then
		endPos = mouse.Hit.Position
	end
end)


mouse.Button1Up:Connect(function()
	if isDrawing then
		isDrawing = false
		if endPos then
			local region = Region3.new(startPos, endPos)
			game.Workspace:FindPartsInRegion3(region, nil, math.huge):Destroy()
		end
	end
end)

mouse.KeyDown:Connect(function(key)
	if key == "t" then
		isDrawing = true
	end
end)

mouse.KeyUp:Connect(function(key)
	if key == "t" then
		isDrawing = false
		if endPos then
			local region = Region3.new(startPos, endPos)
			game.Workspace:FindPartsInRegion3(region, nil, math.huge):Destroy()
		end
	end
end)

I want to make it so that when a player pressed T, and entered the mouse cursor, he could circle the inside of an object, and this circled part would be deleted, but I can not do it, please help me.

FindPartsInRegion3 has been deprecated so I would recommend using GetPartBoundsInBox. It would look something like this:

local Params = OverlapParams.new()

local ObjectsInside = workspace:GetPartBoundsInBox(region.CFrame, region.Size, Params)